/**
  * Create IngestManifestAsset from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\IngestManifestAsset
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['ParentIngestManifestId'], 'options[ParentIngestManifestId]');
     $asset = new self($options['ParentIngestManifestId']);
     $asset->fromArray($options);
     return $asset;
 }
 /**
  * Serialize an object with specified root element name.
  *
  * @param object $targetObject The target object.
  * @param string $rootName     The name of the root element.
  *
  * @return string
  */
 public static function objectSerialize($targetObject, $rootName)
 {
     Validate::notNull($targetObject, 'targetObject');
     Validate::isString($rootName, 'rootName');
     $contianer = new \stdClass();
     $contianer->{$rootName} = $targetObject;
     return json_encode($contianer);
 }
示例#3
0
 /**
  * Adds WRAP authentication header to the request headers.
  *
  * @param HttpClient $request HTTP channel object.
  * 
  * @return \HTTP_Request2
  */
 public function handleRequest($request)
 {
     Validate::notNull($request, 'request');
     $wrapAccessToken = $this->_wrapTokenManager->getAccessToken($request->getUrl());
     $authorization = sprintf(Resources::WRAP_AUTHORIZATION, $wrapAccessToken);
     $request->setHeader(Resources::AUTHENTICATION, $authorization);
     return $request;
 }
 /** 
  * Writes an XML representing the category. 
  * 
  * @param \XMLWriter $xmlWriter The XML writer.
  * 
  * @return none
  */
 public function writeInnerXml($xmlWriter)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     $this->writeOptionalAttribute($xmlWriter, 'term', $this->term);
     $this->writeOptionalAttribute($xmlWriter, 'scheme', $this->scheme);
     $this->writeOptionalAttribute($xmlWriter, 'label', $this->label);
     if (!empty($this->undefinedContent)) {
         $xmlWriter->WriteRaw($this->undefinedContent);
     }
 }
 /** 
  * Serialize an object with specified root element name. 
  * 
  * @param object $targetObject The target object. 
  * @param string $rootName     The name of the root element. 
  * 
  * @return string
  */
 public static function objectSerialize($targetObject, $rootName)
 {
     Validate::notNull($targetObject, 'targetObject');
     Validate::isString($rootName, 'rootName');
     $xmlWriter = new \XmlWriter();
     $xmlWriter->openMemory();
     $xmlWriter->setIndent(true);
     $reflectionClass = new \ReflectionClass($targetObject);
     $methodArray = $reflectionClass->getMethods();
     $attributes = self::_getInstanceAttributes($targetObject, $methodArray);
     $xmlWriter->startElement($rootName);
     if (!is_null($attributes)) {
         foreach (array_keys($attributes) as $attributeKey) {
             $xmlWriter->writeAttribute($attributeKey, $attributes[$attributeKey]);
         }
     }
     foreach ($methodArray as $method) {
         if (strpos($method->name, 'get') === 0 && $method->isPublic() && $method->name != 'getAttributes') {
             $variableName = substr($method->name, 3);
             $variableValue = $method->invoke($targetObject);
             if (!empty($variableValue)) {
                 if (gettype($variableValue) === 'object') {
                     $xmlWriter->writeRaw(XmlSerializer::objectSerialize($variableValue, $variableName));
                 } else {
                     $xmlWriter->writeElement($variableName, $variableValue);
                 }
             }
         }
     }
     $xmlWriter->endElement();
     return $xmlWriter->outputMemory(true);
 }
示例#6
0
 /**
  * Upload asset file to storage.
  *
  * @param WindowsAzure\MediaServices\Models\Locator $locator Write locator for
  * file upload
  *
  * @param string                                    $name    Uploading filename
  * @param string                                    $body    Uploading content
  *
  * @return none
  */
 public function uploadAssetFile($locator, $name, $body)
 {
     Validate::isA($locator, 'WindowsAzure\\Mediaservices\\Models\\Locator', 'locator');
     Validate::isString($name, 'name');
     Validate::notNull($body, 'body');
     $method = Resources::HTTP_PUT;
     $urlFile = $locator->getBaseUri() . '/' . $name;
     $url = new Url($urlFile . $locator->getContentAccessComponent());
     $filters = array();
     $statusCode = Resources::STATUS_CREATED;
     $headers = array(Resources::CONTENT_TYPE => Resources::BINARY_FILE_TYPE, Resources::X_MS_VERSION => Resources::STORAGE_API_LATEST_VERSION, Resources::X_MS_BLOB_TYPE => BlobType::BLOCK_BLOB);
     $httpClient = new HttpClient();
     $httpClient->setMethod($method);
     $httpClient->setHeaders($headers);
     $httpClient->setExpectedStatusCode($statusCode);
     $httpClient->setBody($body);
     $httpClient->send($filters, $url);
 }
示例#7
0
文件: Feed.php 项目: yszar/linuxwp
 /** 
  * Writes an XML representing the feed object.
  * 
  * @param \XMLWriter $xmlWriter The XML writer.
  * 
  * @return none
  */
 public function writeInnerXml($xmlWriter)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     if (!is_null($this->attributes)) {
         if (is_array($this->attributes)) {
             foreach ($this->attributes as $attributeName => $attributeValue) {
                 $xmlWriter->writeAttribute($attributeName, $attributeValue);
             }
         }
     }
     if (!is_null($this->author)) {
         $this->writeArrayItem($xmlWriter, $this->author, Resources::AUTHOR);
     }
     if (!is_null($this->category)) {
         $this->writeArrayItem($xmlWriter, $this->category, Resources::CATEGORY);
     }
     if (!is_null($this->contributor)) {
         $this->writeArrayItem($xmlWriter, $this->contributor, Resources::CONTRIBUTOR);
     }
     if (!is_null($this->generator)) {
         $this->generator->writeXml($xmlWriter);
     }
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'icon', Resources::ATOM_NAMESPACE, $this->icon);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'logo', Resources::ATOM_NAMESPACE, $this->logo);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'id', Resources::ATOM_NAMESPACE, $this->id);
     if (!is_null($this->link)) {
         $this->writeArrayItem($xmlWriter, $this->link, Resources::LINK);
     }
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'rights', Resources::ATOM_NAMESPACE, $this->rights);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'subtitle', Resources::ATOM_NAMESPACE, $this->subtitle);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'title', Resources::ATOM_NAMESPACE, $this->title);
     if (!is_null($this->updated)) {
         $xmlWriter->writeElementNS('atom', 'updated', Resources::ATOM_NAMESPACE, $this->updated->format(\DateTime::ATOM));
     }
 }
 /**
  * Sets the value of a custom property. 
  * 
  * @param string $propertyName  The name of the property.
  * @param mixed  $propertyValue The value of the property.
  * 
  * @return none
  */
 public function setProperty($propertyName, $propertyValue)
 {
     Validate::isString($propertyName, 'propertyName');
     Validate::notNull($propertyValue, 'propertyValue');
     $this->_customProperties[strtolower($propertyName)] = $propertyValue;
 }
 /**
  * Upload asset file to storage.
  *
  * @param WindowsAzure\MediaServices\Models\Locator $locator Write locator for
  * file upload
  *
  * @param string            $name Uploading filename
  * @param string | resource $file Uploading content or file handle
  *
  * @return none
  */
 public function uploadAssetFile($locator, $name, $file)
 {
     Validate::isA($locator, 'WindowsAzure\\Mediaservices\\Models\\Locator', 'locator');
     Validate::isString($name, 'name');
     Validate::notNull($file, 'body');
     $urlFile = $locator->getBaseUri() . '/' . $name;
     $url = $urlFile . $locator->getContentAccessComponent();
     if (is_resource($file)) {
         $this->_uploadAssetFileFromResource($url, $file);
     } else {
         $this->_uploadAssetFileFromString($url, $file);
     }
 }
示例#10
0
 /** 
  * Writes an inner XML representing the content. 
  * 
  * @param \XMLWriter $xmlWriter The XML writer.
  * 
  * @return none
  */
 public function writeInnerXml($xmlWriter)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     $xmlWriter->writeRaw($this->text);
 }
示例#11
0
 /**
  * Create access policy from array
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\AccessPolicy
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['Name'], 'options[Name]');
     $accessPolicy = new AccessPolicy($options['Name']);
     $accessPolicy->fromArray($options);
     return $accessPolicy;
 }
 public static function generateTestToken($template, $verificationKey, $contentKeyUUID, $tokenExpiration = null, $notBefore = null)
 {
     Validate::notNull($template, 'template');
     Validate::isA($template, 'WindowsAzure\\MediaServices\\Templates\\TokenRestrictionTemplate', 'template');
     if ($verificationKey == null) {
         $verificationKey = $template->getPrimaryVerificationKey();
     }
     Validate::notNull($verificationKey, 'verificationKey');
     Validate::isA($verificationKey, 'WindowsAzure\\MediaServices\\Templates\\SymmetricVerificationKey', 'verificationKey');
     if ($tokenExpiration == null) {
         $tokenExpiration = time() + 60 * 10;
     }
     if ($notBefore == null) {
         $notBefore = time() - 60 * 5;
     }
     if ($template->getTokenType() == TokenType::SWT) {
         return TokenRestrictionTemplateSerializer::generateTestTokenSWT($template, $verificationKey, $contentKeyUUID, $tokenExpiration);
     } else {
         return TokenRestrictionTemplateSerializer::generateTestTokenJWT($template, $verificationKey, $contentKeyUUID, $tokenExpiration, $notBefore);
     }
 }
示例#13
0
 /**
  * Updates the visibility timeout of a message and/or the message contents.
  * 
  * @param string              $queueName                  The queue name.
  * @param string              $messageId                  The id of the message.
  * @param string              $popReceipt                 The valid pop receipt 
  * value returned from an earlier call to the Get Messages or Update Message
  * operation.
  * @param string              $messageText                The message contents.
  * @param int                 $visibilityTimeoutInSeconds Specifies the new 
  * visibility timeout value, in seconds, relative to server time. 
  * The new value must be larger than or equal to 0, and cannot be larger 
  * than 7 days. The visibility timeout of a message cannot be set to a value 
  * later than the expiry time. A message can be updated until it has been 
  * deleted or has expired.
  * @param QueueServiceOptions $options                    The optional 
  * parameters.
  * 
  * @return WindowsAzure\Common\Models\UpdateMessageResult
  */
 public function updateMessage($queueName, $messageId, $popReceipt, $messageText, $visibilityTimeoutInSeconds, $options = null)
 {
     Validate::isString($queueName, 'queueName');
     Validate::notNullOrEmpty($queueName, 'queueName');
     Validate::isString($messageId, 'messageId');
     Validate::notNullOrEmpty($messageId, 'messageId');
     Validate::isString($popReceipt, 'popReceipt');
     Validate::notNullOrEmpty($popReceipt, 'popReceipt');
     Validate::isString($messageText, 'messageText');
     Validate::isInteger($visibilityTimeoutInSeconds, 'visibilityTimeoutInSeconds');
     Validate::notNull($visibilityTimeoutInSeconds, 'visibilityTimeoutInSeconds');
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $queueName . '/messages' . '/' . $messageId;
     $body = Resources::EMPTY_STRING;
     $statusCode = Resources::STATUS_NO_CONTENT;
     if (is_null($options)) {
         $options = new QueueServiceOptions();
     }
     $this->addOptionalQueryParam($queryParams, Resources::QP_VISIBILITY_TIMEOUT, $visibilityTimeoutInSeconds);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalQueryParam($queryParams, Resources::QP_POPRECEIPT, $popReceipt);
     if (!empty($messageText)) {
         $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE);
         $message = new QueueMessage();
         $message->setMessageText($messageText);
         $body = $message->toXml($this->dataSerializer);
     }
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode, $body);
     $popReceipt = $response->getHeader(Resources::X_MS_POPRECEIPT);
     $timeNextVisible = $response->getHeader(Resources::X_MS_TIME_NEXT_VISIBLE);
     $date = Utilities::rfc1123ToDateTime($timeNextVisible);
     $result = new UpdateMessageResult();
     $result->setPopReceipt($popReceipt);
     $result->setTimeNextVisible($date);
     return $result;
 }
示例#14
0
 /**
  * Create asset from array
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\JobTemplate
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['JobTemplateBody'], 'options[JobTemplateBody]');
     $jobTemplate = new JobTemplate($options['JobTemplateBody'], $options['TemplateType']);
     $jobTemplate->fromArray($options);
     return $jobTemplate;
 }
 /**
  * Create task template from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\TaskTemplate
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['NumberofInputAssets'], 'options[NumberofInputAssets]');
     Validate::notNull($options['NumberofOutputAssets'], 'options[NumberofOutputAssets]');
     $taskTemplate = new self($options['NumberofInputAssets'], $options['NumberofOutputAssets']);
     $taskTemplate->fromArray($options);
     return $taskTemplate;
 }
示例#16
0
 /** 
  * Writes a inner XML representing the person. 
  * 
  * @param \XMLWriter $xmlWriter The XML writer.
  * 
  * @return none
  */
 public function writeInnerXml($xmlWriter)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     $xmlWriter->writeElementNS('atom', 'name', Resources::ATOM_NAMESPACE, $this->name);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'uri', Resources::ATOM_NAMESPACE, $this->uri);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'email', Resources::ATOM_NAMESPACE, $this->email);
 }
示例#17
0
文件: Task.php 项目: mat33470/PFA
 /**
  * Create task from array
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\Task
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['TaskBody'], 'options[TaskBody]');
     Validate::notNull($options['Options'], 'options[Options]');
     Validate::notNull($options['MediaProcessorId'], 'options[MediaProcessorId]');
     $task = new Task($options['TaskBody'], $options['MediaProcessorId'], $options['Options']);
     $task->fromArray($options);
     return $task;
 }
 /**
  * Creates a new file.
  *
  * @param string                   $share         The share name.
  * @param string                   $directoryPath The directory path.
  * @param string                   $file          The name of file
  * @param integer                  $length        Specifies the maximum size for the
  *                                                file, up to 1 TB. The file size must be aligned to a 512-byte
  *                                                boundary.
  * @param Models\CreateFileOptions $options       The optional parameters.
  *
  * @return FileResult
  *
  * @see https://msdn.microsoft.com/en-us/library/azure/dn194271.aspx
  */
 public function createFile($share, $directoryPath, $file, $length, $options = null)
 {
     Validate::isString($share, 'share');
     Validate::isString($directoryPath, 'directoryPath');
     Validate::isString($file, 'file');
     Validate::isInteger($length, 'length');
     Validate::notNull($length, 'length');
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $this->_createPath($share, $directoryPath, $file);
     $statusCode = Resources::STATUS_CREATED;
     if (is_null($options)) {
         $options = new CreateFileOptions();
     }
     $headers[Resources::X_MS_TYPE] = Resources::FILE_TYPE;
     $headers[Resources::X_MS_CONTENT_LENGTH] = $length;
     $headers = $this->_addCreateFileOptionalHeaders($options, $headers);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     return FileResult::create($response->getHeader());
 }
 /**
  * Send Update Program operation
  *
  * @param Models\Programs $program Programs data
  *
  * @return Models\Operation The operation to track the program update.
  */
 public function sendUpdateProgramOperation($program)
 {
     Validate::isA($program, 'WindowsAzure\\MediaServices\\Models\\Program', 'program');
     $programId = $program->getId();
     Validate::notNull($programId, "programId");
     return $this->_sendOperation($program, "Programs('{$programId}')", Resources::HTTP_MERGE, [Resources::STATUS_ACCEPTED, Resources::STATUS_NO_CONTENT]);
 }
 /**
  * Get object properties as array
  *
  * @param object     $object    Source object
  * @param \XMLWriter $xmlWriter Xml writer to use
  *
  * @return  array
  */
 private static function _serializeRecursive($object, $xmlWriter)
 {
     Validate::notNull($object, 'object');
     $reflectionClass = new \ReflectionClass($object);
     $methodArray = $reflectionClass->getMethods();
     $result = array();
     foreach ($methodArray as $method) {
         if (strpos($method->name, 'get') === 0 && $method->isPublic()) {
             $variableName = substr($method->name, 3);
             $variableValue = $method->invoke($object);
             if (!empty($variableValue) || ContentPropertiesSerializer::_isRequired($object, $variableName)) {
                 if (is_a($variableValue, '\\DateTime')) {
                     $variableValue = $variableValue->format(\DateTime::ATOM);
                 }
                 if (gettype($variableValue) == 'array') {
                     $xmlWriter->startElementNS('data', $variableName, Resources::DS_XML_NAMESPACE);
                     foreach ($variableValue as $item) {
                         $xmlWriter->startElementNS('data', Resources::ELEMENT, Resources::DS_XML_NAMESPACE);
                         ContentPropertiesSerializer::_serializeRecursive($item, $xmlWriter);
                         $xmlWriter->endElement();
                     }
                     $xmlWriter->endElement();
                 } else {
                     if (gettype($variableValue) == 'object') {
                         $xmlWriter->startElementNS('data', $variableName, Resources::DS_XML_NAMESPACE);
                         ContentPropertiesSerializer::_serializeRecursive($variableValue, $xmlWriter);
                         $xmlWriter->endElement();
                     } else {
                         $xmlWriter->writeElementNS('data', $variableName, Resources::DS_XML_NAMESPACE, (string) $variableValue);
                     }
                 }
             }
         }
     }
     return $result;
 }
示例#21
0
文件: Entry.php 项目: yszar/linuxwp
 /**
  * Writes a inner XML string representing the entry.
  *
  * @param \XMLWriter $xmlWriter The XML writer.
  *
  * @return none
  */
 public function writeXml($xmlWriter)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     $xmlWriter->startElementNS('atom', Resources::ENTRY, Resources::ATOM_NAMESPACE);
     $this->writeInnerXml($xmlWriter);
     $xmlWriter->endElement();
 }
示例#22
0
 /**
  * Writes the optional elements namespaces.
  *
  * @param \XmlWriter $xmlWriter    The XML writer.
  * @param string     $prefix       The prefix.
  * @param string     $elementName  The element name.
  * @param string     $namespace    The namespace name.
  * @param string     $elementValue The element value.
  *
  * @return none
  */
 protected function writeOptionalElementNS($xmlWriter, $prefix, $elementName, $namespace, $elementValue)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     Validate::isString($elementName, 'elementName');
     if (!empty($elementValue)) {
         $xmlWriter->writeElementNS($prefix, $elementName, $namespace, $elementValue);
     }
 }
示例#23
0
 /**
  * Validate if method exists in object
  *
  * @param object $objectInstance An object that requires method existing
  *                               validation
  * @param string $method         Method name
  * @param string $name           The parameter name
  *
  * @return boolean
  */
 public static function methodExists($objectInstance, $method, $name)
 {
     Validate::isString($method, 'method');
     Validate::notNull($objectInstance, 'objectInstance');
     Validate::isObject($objectInstance, 'objectInstance');
     if (method_exists($objectInstance, $method)) {
         return true;
     } else {
         throw new \InvalidArgumentException(sprintf(Resources::ERROR_METHOD_NOT_FOUND, $method, $name));
     }
 }
示例#24
0
 /**
  * Creates a new page blob. Note that calling createPageBlob to create a page
  * blob only initializes the blob.
  * To add content to a page blob, call createBlobPages method.
  * 
  * @param string                   $container The container name.
  * @param string                   $blob      The blob name.
  * @param integer                  $length    Specifies the maximum size for the
  * page blob, up to 1 TB. The page blob size must be aligned to a 512-byte 
  * boundary.
  * @param Models\CreateBlobOptions $options   The optional parameters.
  * 
  * @return CopyBlobResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
  */
 public function createPageBlob($container, $blob, $length, $options = null)
 {
     Validate::isString($container, 'container');
     Validate::isString($blob, 'blob');
     Validate::notNullOrEmpty($blob, 'blob');
     Validate::isInteger($length, 'length');
     Validate::notNull($length, 'length');
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $this->_createPath($container, $blob);
     $statusCode = Resources::STATUS_CREATED;
     if (is_null($options)) {
         $options = new CreateBlobOptions();
     }
     $this->addOptionalHeader($headers, Resources::X_MS_BLOB_TYPE, BlobType::PAGE_BLOB);
     $this->addOptionalHeader($headers, Resources::X_MS_BLOB_CONTENT_LENGTH, $length);
     $this->addOptionalHeader($headers, Resources::X_MS_BLOB_SEQUENCE_NUMBER, $options->getSequenceNumber());
     $headers = $this->_addCreateBlobOptionalHeaders($options, $headers);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     return CopyBlobResult::create($response->getHeader());
 }
示例#25
0
 /** 
  * Writes the inner XML representing the ATOM link item.
  * 
  * @param \XMLWriter $xmlWriter The xml writer.
  * 
  * @return none
  */
 public function writeInnerXml($xmlWriter)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     $this->writeOptionalAttribute($xmlWriter, 'href', $this->href);
     $this->writeOptionalAttribute($xmlWriter, 'rel', $this->rel);
     $this->writeOptionalAttribute($xmlWriter, 'type', $this->type);
     $this->writeOptionalAttribute($xmlWriter, 'hreflang', $this->hreflang);
     $this->writeOptionalAttribute($xmlWriter, 'title', $this->title);
     $this->writeOptionalAttribute($xmlWriter, 'length', $this->length);
     if (!empty($this->undefinedContent)) {
         $xmlWriter->writeRaw($this->undefinedContent);
     }
 }
示例#26
0
 /**
  * Create TokenClaim
  *
  * @return void
  */
 public function __construct($type, $value = null)
 {
     Validate::notNull($type, 'type');
     $this->_claimType = $type;
     $this->_claimValue = $value;
 }
示例#27
0
 /**
  * Create locator from array
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\Locator
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['AssetId'], 'options[AssetId]');
     Validate::notNull($options['AccessPolicyId'], 'options[AccessPolicyId]');
     Validate::notNull($options['Type'], 'options[Type]');
     $locator = new Locator($options['AssetId'], $options['AccessPolicyId'], $options['Type']);
     $locator->fromArray($options);
     return $locator;
 }
示例#28
0
 /**
  * Constructor.
  *
  * @param string                                      $accountName  account name.
  * @param string                                      $accountKey   account
  * secondary key.
  *
  * @param string                                      $grantType    grant type
  * for OAuth request.
  *
  * @param string                                      $scope        scope for
  * OAurh request.
  *
  * @param WindowsAzure\Common\Internal\OAuthRestProxy $oauthService account
  * primary or secondary key.
  */
 public function __construct($accountName, $accountKey, $grantType, $scope, $oauthService)
 {
     Validate::isString($accountName, 'accountName');
     Validate::isString($accountKey, 'accountKey');
     Validate::isString($grantType, 'grantType');
     Validate::isString($scope, 'scope');
     Validate::notNull($oauthService, 'oauthService');
     $this->accountName = $accountName;
     $this->accountKey = $accountKey;
     $this->grantType = $grantType;
     $this->scope = $scope;
     $this->oauthService = $oauthService;
 }
示例#29
0
 /**
  * Create asset file from array
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\AssetFile
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['Name'], 'options[Name]');
     Validate::notNull($options['ParentAssetId'], 'options[ParentAssetId]');
     $assetFile = new AssetFile($options['Name'], $options['ParentAssetId']);
     $assetFile->fromArray($options);
     return $assetFile;
 }
示例#30
0
 /**
  * Create asset from array
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\Asset
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['Options'], 'options[Options]');
     $asset = new Asset($options['Options']);
     $asset->fromArray($options);
     return $asset;
 }