/** * Fill VideoStream from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['Index'])) { Validate::isInteger($options['Index'], 'options[Index]'); $this->_index = (int) $options['Index']; } }
/** * Fill ChannelOutput from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['Hls'])) { Validate::isArray($options['Hls'], 'options[Hls]'); $this->_hls = ChannelOutputHls::createFromOptions($options['Hls']); } }
/** * Fill ChannelOutputHls from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['FragmentsPerSegment'])) { Validate::isInteger($options['FragmentsPerSegment'], 'options[FragmentsPerSegment]'); $this->_fragmentsPerSegment = (int) $options['FragmentsPerSegment']; } }
/** * Fill ChannelPreviewAccessControl from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (!empty($options['IP'])) { Validate::isArray($options['IP'], 'options[IP]'); $this->_ip = IPAccessControl::createFromOptions($options['IP']); } }
/** * 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; }
/** * Creates new object based on the builder type in the $config. * * @param WindowsAzure\Common\Configuration $config The config * object. * @param WindowsAzure\Common\Internal\IServicesBuilder $builder The builder * object. * * @return WindowsAzure\Blob\BlobRestProxy */ public static function create($config, $builder = null) { Validate::isTrue($config instanceof Configuration, Resources::INVALID_CONFIG_MSG); if (!is_null($builder)) { Validate::isTrue($builder instanceof IServiceBuilder, Resources::INVALID_BUILDER_MSG); } return $config->create(Resources::BLOB_TYPE_NAME, $builder); }
/** * Fill IPRange from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['Allow'])) { Validate::isArray($options['Allow'], 'options[Allow]'); foreach ($options['Allow'] as $allow) { $this->_allow[] = IPRange::createFromOptions($allow); } } }
/** * Adds new entry to the block list entries. * * @param string $blockId The block id. * @param string $type The entry type, you can use BlobBlockType. * * @return none */ public function addEntry($blockId, $type) { Validate::isString($blockId, 'blockId'); Validate::isTrue(BlobBlockType::isValid($type), sprintf(Resources::INVALID_BTE_MSG, get_class(new BlobBlockType()))); $block = new Block(); $block->setBlockId($blockId); $block->setType($type); $this->_entries[] = $block; }
/** * Constructor * * @param string $incarnation The incarnation. * @param string $expectedState The expected state. * @param string $environmentPath The environment path. * @param \DateTime $deadline The deadline. * @param string $currentStateEndpoint The current state endpoint. */ public function __construct($incarnation, $expectedState, $environmentPath, $deadline, $currentStateEndpoint) { Validate::isDate($deadline); $this->_incarnation = $incarnation; $this->_expectedState = $expectedState; $this->_environmentPath = $environmentPath; $this->_deadline = $deadline; $this->_currentStateEndpoint = $currentStateEndpoint; }
/** * Unserializes given serialized string to array. * * @param string $serialized The serialized object in string representation. * * @return array */ public function unserialize($serialized) { Validate::isString($serialized, 'serialized'); $json = json_decode($serialized); if ($json && !is_array($json)) { return get_object_vars($json); } else { return $json; } }
/** * Creates an RuleInfo with specified parameters. * * @param string $title The title of the rule. * @param RuleDescription $ruleDescription The description of the rule. */ public function __construct($title = Resources::EMPTY_STRING, $ruleDescription = null) { Validate::isString($title, 'title'); if (is_null($ruleDescription)) { $ruleDescription = new RuleDescription(); } $this->_ruleDescription = $ruleDescription; $this->_entry = new Entry(); $this->_entry->setTitle($title); $this->_entry->setAttribute(Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE); }
/** * Fill ChannelEndpoint from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['Protocol'])) { Validate::isString($options['Protocol'], 'options[Protocol]'); $this->_protocol = $options['Protocol']; } if (isset($options['Url'])) { Validate::isString($options['Url'], 'options[Url]'); $this->_url = $options['Url']; } }
/** * Fill ContentKeyAuthorizationPolicy from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } }
/** * Fill ChannelSlate from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['InsertSlateOnAdMarker'])) { Validate::isBoolean($options['InsertSlateOnAdMarker'], 'options[InsertSlateOnAdMarker]'); $this->_insertSlateOnAdMarker = (bool) $options['InsertSlateOnAdMarker']; } if (isset($options['DefaultSlateAssetId'])) { Validate::isString($options['DefaultSlateAssetId'], 'options[DefaultSlateAssetIdUrl]'); $this->_defaultSlateAssetId = $options['DefaultSlateAssetId']; } }
/** * Fill error detail from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Code'])) { Validate::isInteger($options['Code'], 'options[Code]'); $this->_code = $options['Code']; } if (isset($options['Message'])) { Validate::isString($options['Message'], 'options[Message]'); $this->_message = $options['Message']; } }
/** * Creates BatchError object. * * @param WindowsAzure\Common\ServiceException $error The error object. * @param array $headers The response headers. * * @return \WindowsAzure\Table\Models\BatchError */ public static function create($error, $headers) { Validate::isTrue($error instanceof ServiceException, Resources::INVALID_EXC_OBJ_MSG); Validate::isArray($headers, 'headers'); $result = new BatchError(); $clean = array_change_key_case($headers); $result->setError($error); $contentId = Utilities::tryGetValue($clean, Resources::CONTENT_ID); $result->setContentId(is_null($contentId) ? null : intval($contentId)); return $result; }
/** * Fill storage account from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['IsDefault'])) { Validate::isBoolean($options['IsDefault'], 'options[IsDefault]'); $this->_isDefault = $options['IsDefault']; } }
/** * Fill CrossSiteAccessPolicies from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['ClientAccessPolicy'])) { Validate::isString($options['ClientAccessPolicy'], 'options[ClientAccessPolicy]'); $this->_clientAccessPolicy = $options['ClientAccessPolicy']; } if (isset($options['CrossDomainPolicy'])) { Validate::isString($options['CrossDomainPolicy'], 'options[CrossDomainPolicy]'); $this->_crossDomainPolicy = $options['CrossDomainPolicy']; } }
/** * Constructor * * @param string $content Http response * as string * * @param WindowsAzure\Common\Internal\Http\BatchRequest $request Source batch * request object */ public function __construct($content, $request = null) { $params['include_bodies'] = true; $params['input'] = $content; $mimeDecoder = new \Mail_mimeDecode($content); $structure = $mimeDecoder->decode($params); $parts = $structure->parts; $this->_contexts = array(); $requestContexts = null; if ($request != null) { Validate::isA($request, 'WindowsAzure\\Common\\Internal\\Http\\BatchRequest', 'request'); $requestContexts = $request->getContexts(); } $i = 0; foreach ($parts as $part) { if (!empty($part->body)) { $headerEndPos = strpos($part->body, "\r\n\r\n"); $header = substr($part->body, 0, $headerEndPos); $body = substr($part->body, $headerEndPos + 4); $headerStrings = explode("\r\n", $header); $response = new \HTTP_Request2_Response(array_shift($headerStrings)); foreach ($headerStrings as $headerString) { $response->parseHeaderLine($headerString); } $response->appendBody($body); $this->_contexts[] = $response; if (is_array($requestContexts)) { $expectedCodes = $requestContexts[$i]->getStatusCodes(); $statusCode = $response->getStatus(); if (!in_array($statusCode, $expectedCodes)) { $reason = $response->getReasonPhrase(); throw new ServiceException($statusCode, $reason, $body); } } $i++; } } }
/** * Fill asset file from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['ContentFileSize'])) { Validate::isString($options['ContentFileSize'], 'options[ContentFileSize]'); $this->_contentFileSize = $options['ContentFileSize']; } if (isset($options['ParentAssetId'])) { Validate::isString($options['ParentAssetId'], 'options[ParentAssetId]'); $this->_parentAssetId = $options['ParentAssetId']; } if (isset($options['EncryptionVersion'])) { Validate::isString($options['EncryptionVersion'], 'options[EncryptionVersion]'); $this->_encryptionVersion = $options['EncryptionVersion']; } if (isset($options['EncryptionScheme'])) { Validate::isString($options['EncryptionScheme'], 'options[EncryptionScheme]'); $this->_encryptionScheme = $options['EncryptionScheme']; } if (isset($options['IsEncrypted'])) { Validate::isBoolean($options['IsEncrypted'], 'options[IsEncrypted]'); $this->_isEncrypted = $options['IsEncrypted']; } if (isset($options['EncryptionKeyId'])) { Validate::isString($options['EncryptionKeyId'], 'options[EncryptionKeyId]'); $this->_encryptionKeyId = $options['EncryptionKeyId']; } if (isset($options['InitializationVector'])) { Validate::isString($options['InitializationVector'], 'options[InitializationVector]'); $this->_initializationVector = $options['InitializationVector']; } if (isset($options['IsPrimary'])) { Validate::isBoolean($options['IsPrimary'], 'options[IsPrimary]'); $this->_isPrimary = $options['IsPrimary']; } if (isset($options['LastModified'])) { Validate::isDateString($options['LastModified'], 'options[LastModified]'); $this->_lastModified = new \DateTime($options['LastModified']); } if (isset($options['Created'])) { Validate::isDateString($options['Created'], 'options[Created]'); $this->_created = new \DateTime($options['Created']); } if (isset($options['MimeType'])) { Validate::isString($options['MimeType'], 'options[MimeType]'); $this->_mimeType = $options['MimeType']; } if (isset($options['ContentChecksum'])) { Validate::isString($options['ContentChecksum'], 'options[ContentChecksum]'); $this->_contentCheckSum = $options['ContentChecksum']; } }
/** * Sets blob sequenceNumber. * * @param int $sequenceNumber value. * * @return none. */ public function setSequenceNumber($sequenceNumber) { Validate::isInteger($sequenceNumber, 'sequenceNumber'); $this->_sequenceNumber = $sequenceNumber; }
/** * Adds status code to the expected status codes. * * @param integer $statusCode The expected status code. * * @return none */ public function addStatusCode($statusCode) { Validate::isInteger($statusCode, 'statusCode'); $this->_statusCodes[] = $statusCode; }
/** * @covers WindowsAzure\Common\Internal\Validate::notNull */ public function testNotNullWithNull() { $this->setExpectedException('\\InvalidArgumentException'); Validate::notNullOrEmpty(null, 'variable'); }
/** * Fill task historical event from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Code'])) { Validate::isInteger($options['Code'], 'options[Code]'); $this->_code = $options['Code']; } if (isset($options['Message'])) { Validate::isString($options['Message'], 'options[Message]'); $this->_message = $options['Message']; } if (isset($options['TimeStamp'])) { Validate::isDateString($options['TimeStamp'], 'options[TimeStamp]'); $this->_timeStamp = new \DateTime($options['TimeStamp']); } }
/** * Sets blob contentLength. * * @param integer $contentLength value. * * @return none. */ public function setContentLength($contentLength) { Validate::isInteger($contentLength, 'contentLength'); $this->_contentLength = $contentLength; }
/** * Fill Encoding from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['AdMarkerSource'])) { Validate::isString($options['AdMarkerSource'], 'options[AdMarkerSource]'); $this->_adMarkerSource = $options['AdMarkerSource']; } if (isset($options['IgnoreCea708ClosedCaptions'])) { Validate::isString($options['IgnoreCea708ClosedCaptions'], 'options[IgnoreCea708ClosedCaptions]'); $this->_ignoreCea708ClosedCaptions = (bool) $options['IgnoreCea708ClosedCaptions']; } if (!empty($options['VideoStreams'])) { Validate::isArray($options['VideoStreams'], 'options[VideoStreams]'); foreach ($options['VideoStreams'] as $videoStream) { $this->_videoStreams[] = VideoStream::createFromOptions($videoStream); } } if (!empty($options['AudioStreams'])) { Validate::isArray($options['AudioStreams'], 'options[AudioStreams]'); foreach ($options['AudioStreams'] as $audioStream) { $this->_audioStreams[] = AudioStream::createFromOptions($audioStream); } } if (isset($options['SystemPreset'])) { Validate::isString($options['SystemPreset'], 'options[SystemPreset]'); $this->_systemPreset = $options['SystemPreset']; } }
/** * Sets blob etag. * * @param string $etag value. * * @return none. */ public function setETag($etag) { Validate::isString($etag, 'etag'); $this->_etag = $etag; }
/** * Sets the include metadata flag. * * @param bool $includeMetadata value. * * @return none. */ public function setIncludeMetadata($includeMetadata) { Validate::isBoolean($includeMetadata); $this->_includeMetadata = $includeMetadata; }
/** * Creates a topic with specified topic info. * * @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780728 * * @param TopicInfo $topicInfo The information of the topic. * * @return TopicInfo */ public function createTopic($topicInfo) { Validate::notNullOrEmpty($topicInfo, 'topicInfo'); $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $httpCallContext->setPath($topicInfo->getTitle()); $httpCallContext->addHeader(Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $topicDescriptionXml = XmlSerializer::objectSerialize($topicInfo->getTopicDescription(), 'TopicDescription'); $entry = new Entry(); $content = new Content($topicDescriptionXml); $content->setType(Resources::XML_CONTENT_TYPE); $entry->setContent($content); $entry->setAttribute(Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE); $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $entry->writeXml($xmlWriter); $httpCallContext->setBody($xmlWriter->outputMemory()); $response = $this->sendContext($httpCallContext); $topicInfo = new TopicInfo(); $topicInfo->parseXml($response->getBody()); return $topicInfo; }
/** * Sets rangeEnd * * @param integer $rangeEnd range end value in bytes * * @return none */ public function setRangeEnd($rangeEnd) { Validate::isInteger($rangeEnd, 'rangeEnd'); $this->_rangeEnd = $rangeEnd; }