_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q255400 | ConnectionStringParser._extractKey | test | private function _extractKey()
{
$key = null;
$firstPos = $this->_pos;
$ch = $this->_value[$this->_pos];
if ($ch == '"' || $ch == '\'') {
$this->_pos++;
$key = $this->_extractString($ch);
} elseif ($ch == ';' || $ch == '=') {
// Key name was expected.
throw $this->_createException(
$firstPos,
Resources::ERROR_CONNECTION_STRING_MISSING_KEY
);
} else {
while ($this->_pos < strlen($this->_value)) {
$ch = $this->_value[$this->_pos];
// At this point we've read the key, break.
if ($ch == '=') {
break;
}
$this->_pos++;
}
$key = rtrim(substr($this->_value, $firstPos, $this->_pos - $firstPos));
}
if (strlen($key) == 0) {
// Empty key name.
throw $this->_createException(
$firstPos,
Resources::ERROR_CONNECTION_STRING_EMPTY_KEY
);
}
return $key;
} | php | {
"resource": ""
} |
q255401 | ConnectionStringParser._extractString | test | private function _extractString($quote)
{
$firstPos = $this->_pos;
while ($this->_pos < strlen($this->_value)
&& $this->_value[$this->_pos] != $quote
) {
$this->_pos++;
}
if ($this->_pos == strlen($this->_value)) {
// Runaway string.
throw $this->_createException(
$this->_pos,
Resources::ERROR_CONNECTION_STRING_MISSING_CHARACTER,
$quote
);
}
return substr($this->_value, $firstPos, $this->_pos++ - $firstPos);
} | php | {
"resource": ""
} |
q255402 | ConnectionStringParser._skipOperator | test | private function _skipOperator($operatorChar)
{
if ($this->_value[$this->_pos] != $operatorChar) {
// Character was expected.
throw $this->_createException(
$this->_pos,
Resources::MISSING_CONNECTION_STRING_CHAR,
$operatorChar
);
}
$this->_pos++;
} | php | {
"resource": ""
} |
q255403 | GetShareACLResult.create | test | public static function create(
$etag,
\DateTime $lastModified,
array $parsed = null
) {
$result = new GetShareAclResult();
$result->setETag($etag);
$result->setLastModified($lastModified);
$acl = ShareACL::create($parsed);
$result->setShareAcl($acl);
return $result;
} | php | {
"resource": ""
} |
q255404 | CommonRequestMiddleware.onRequest | test | protected function onRequest(RequestInterface $request)
{
$result = $request;
//Adding headers.
foreach ($this->headers as $key => $value) {
$headers = $result->getHeaders();
if (!array_key_exists($key, $headers)) {
$result = $result->withHeader($key, $value);
}
}
//rewriting version and user-agent.
$result = $result->withHeader(
Resources::X_MS_VERSION,
$this->msVersion
);
$result = $result->withHeader(
Resources::USER_AGENT,
$this->userAgent
);
//Adding date.
$date = gmdate(Resources::AZURE_DATE_FORMAT, time());
$result = $result->withHeader(Resources::DATE, $date);
//Adding request-ID if not specified by the user.
if (!$result->hasHeader(Resources::X_MS_REQUEST_ID)) {
$result = $result->withHeader(Resources::X_MS_REQUEST_ID, \uniqid());
}
//Sign the request if authentication scheme is not null.
$request = $this->authenticationScheme == null ?
$request : $this->authenticationScheme->signRequest($result);
return $request;
} | php | {
"resource": ""
} |
q255405 | ServiceSettings.settingWithFunc | test | protected static function settingWithFunc($name, $predicate)
{
$requirement = array();
$requirement[Resources::SETTING_NAME] = $name;
$requirement[Resources::SETTING_CONSTRAINT] = $predicate;
return $requirement;
} | php | {
"resource": ""
} |
q255406 | ServiceSettings.setting | test | protected static function setting($name)
{
$validValues = func_get_args();
// Remove $name argument.
unset($validValues[0]);
$validValuesCount = func_num_args();
$predicate = function ($settingValue) use ($validValuesCount, $validValues) {
if (empty($validValues)) {
// No restrictions, succeed,
return true;
}
// Check to find if the $settingValue is valid or not. The index must
// start from 1 as unset deletes the value but does not update the array
// indecies.
for ($index = 1; $index < $validValuesCount; $index++) {
if ($settingValue == $validValues[$index]) {
// $settingValue is found in valid values set, succeed.
return true;
}
}
throw new \RuntimeException(
sprintf(
Resources::INVALID_CONFIG_VALUE,
$settingValue,
implode("\n", $validValues)
)
);
// $settingValue is missing in valid values set, fail.
return false;
};
return self::settingWithFunc($name, $predicate);
} | php | {
"resource": ""
} |
q255407 | ServiceSettings.matchedSpecification | test | protected static function matchedSpecification(array $settings)
{
$constraints = func_get_args();
// Remove first element which corresponds to $settings
unset($constraints[0]);
foreach ($constraints as $constraint) {
$remainingSettings = $constraint($settings);
if (is_null($remainingSettings)) {
return false;
} else {
$settings = $remainingSettings;
}
}
if (empty($settings)) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q255408 | TableContinuationTokenTrait.setNextRowKey | test | public function setNextRowKey($nextRowKey)
{
if ($this->continuationToken == null) {
$this->setContinuationToken(new TableContinuationToken());
}
$this->continuationToken->setNextRowKey($nextRowKey);
} | php | {
"resource": ""
} |
q255409 | TableContinuationTokenTrait.setNextPartitionKey | test | public function setNextPartitionKey($nextPartitionKey)
{
if ($this->continuationToken == null) {
$this->setContinuationToken(new TableContinuationToken());
}
$this->continuationToken->setNextPartitionKey($nextPartitionKey);
} | php | {
"resource": ""
} |
q255410 | EdmType.processType | test | public static function processType($type)
{
$type = empty($type) ? self::STRING : $type;
Validate::isTrue(self::isValid($type), Resources::INVALID_EDM_MSG);
return $type;
} | php | {
"resource": ""
} |
q255411 | EdmType.validateEdmValue | test | public static function validateEdmValue($type, $value, &$condition = null)
{
// Having null value means that the user wants to remove the property name
// associated with this value. Leave the value as null so this hold.
if (is_null($value)) {
return true;
} else {
switch ($type) {
case EdmType::GUID:
case EdmType::BINARY:
case EdmType::STRING:
case EdmType::INT64:
case null:
// NULL also is treated as EdmType::STRING
$condition = 'is_string';
return is_string($value);
case EdmType::DOUBLE:
$condition = 'is_double or is_string';
return is_double($value) || is_int($value) || is_string($value);
case EdmType::INT32:
$condition = 'is_int or is_string';
return is_int($value) || is_string($value);
case EdmType::DATETIME:
$condition = 'instanceof \DateTime';
return $value instanceof \DateTime;
case EdmType::BOOLEAN:
$condition = 'is_bool';
return is_bool($value);
default:
throw new \InvalidArgumentException();
}
}
} | php | {
"resource": ""
} |
q255412 | EdmType.serializeValue | test | public static function serializeValue($type, $value)
{
switch ($type) {
case null:
return $value;
case EdmType::INT32:
return intval($value);
case EdmType::INT64:
case EdmType::GUID:
case EdmType::STRING:
return strval($value);
case EdmType::DOUBLE:
return strval($value);
case EdmType::BINARY:
return base64_encode($value);
case EdmType::DATETIME:
return Utilities::convertToEdmDateTime($value);
case EdmType::BOOLEAN:
return (is_null($value) ? '' : ($value == true ? true : false));
default:
throw new \InvalidArgumentException();
}
} | php | {
"resource": ""
} |
q255413 | EdmType.serializeQueryValue | test | public static function serializeQueryValue($type, $value)
{
switch ($type) {
case EdmType::DATETIME:
$edmDate = Utilities::convertToEdmDateTime($value);
return 'datetime\'' . $edmDate . '\'';
case EdmType::BINARY:
return 'X\'' . implode('', unpack("H*", $value)) . '\'';
case EdmType::BOOLEAN:
return ($value ? 'true' : 'false');
case EdmType::DOUBLE:
case EdmType::INT32:
return $value;
case EdmType::INT64:
return $value . 'L';
case EdmType::GUID:
return 'guid\'' . $value . '\'';
case null:
case EdmType::STRING:
// NULL also is treated as EdmType::STRING
return '\'' . str_replace('\'', '\'\'', $value) . '\'';
default:
throw new \InvalidArgumentException();
}
} | php | {
"resource": ""
} |
q255414 | EdmType.unserializeQueryValue | test | public static function unserializeQueryValue($type, $value)
{
// Having null value means that the user wants to remove the property name
// associated with this value. Leave the value as null so this hold.
if (is_null($value)) {
return null;
} else {
switch ($type) {
case self::GUID:
case self::STRING:
case self::INT64:
case null:
return strval($value);
case self::BINARY:
return base64_decode($value);
case self::DATETIME:
return Utilities::convertToDateTime($value);
case self::BOOLEAN:
return Utilities::toBoolean($value);
case self::DOUBLE:
return doubleval($value);
case self::INT32:
return intval($value);
default:
throw new \InvalidArgumentException();
}
}
} | php | {
"resource": ""
} |
q255415 | ServiceProperties.create | test | public static function create(array $parsedResponse)
{
$result = new ServiceProperties();
if (array_key_exists(Resources::XTAG_DEFAULT_SERVICE_VERSION, $parsedResponse) &&
$parsedResponse[Resources::XTAG_DEFAULT_SERVICE_VERSION] != null) {
$result->setDefaultServiceVersion($parsedResponse[Resources::XTAG_DEFAULT_SERVICE_VERSION]);
}
if (array_key_exists(Resources::XTAG_LOGGING, $parsedResponse)) {
$result->setLogging(Logging::create($parsedResponse[Resources::XTAG_LOGGING]));
}
$result->setHourMetrics(Metrics::create($parsedResponse[Resources::XTAG_HOUR_METRICS]));
if (array_key_exists(Resources::XTAG_MINUTE_METRICS, $parsedResponse)) {
$result->setMinuteMetrics(Metrics::create($parsedResponse[Resources::XTAG_MINUTE_METRICS]));
}
if (array_key_exists(Resources::XTAG_CORS, $parsedResponse) &&
$parsedResponse[Resources::XTAG_CORS] != null) {
//There could be multiple CORS rules, so need to extract them all.
$corses = array();
$corsArray =
$parsedResponse[Resources::XTAG_CORS][Resources::XTAG_CORS_RULE];
if (count(array_filter(array_keys($corsArray), 'is_string')) > 0) {
//single cors rule
$corses[] = CORS::create($corsArray);
} else {
//multiple cors rule
foreach ($corsArray as $cors) {
$corses[] = CORS::create($cors);
}
}
$result->setCorses($corses);
} else {
$result->setCorses(array());
}
return $result;
} | php | {
"resource": ""
} |
q255416 | ServiceProperties.getCorsesArray | test | private function getCorsesArray()
{
$corsesArray = array();
if (count($this->getCorses()) == 1) {
$corsesArray = array(
Resources::XTAG_CORS_RULE => $this->getCorses()[0]->toArray()
);
} elseif ($this->getCorses() != array()) {
foreach ($this->getCorses() as $cors) {
$corsesArray[] = [Resources::XTAG_CORS_RULE => $cors->toArray()];
}
}
return $corsesArray;
} | php | {
"resource": ""
} |
q255417 | ConnectionStringSource._init | test | private static function _init()
{
if (!self::$_isInitialized) {
self::$_defaultSources = array(
self::ENVIRONMENT_SOURCE => array(__CLASS__, 'environmentSource')
);
self::$_isInitialized = true;
}
} | php | {
"resource": ""
} |
q255418 | JsonODataReaderWriter.parseTableEntries | test | public function parseTableEntries($body)
{
$tables = array();
$result = json_decode($body, true);
$rawEntries = $result[Resources::JSON_VALUE];
foreach ($rawEntries as $entry) {
$tables[] = $entry[Resources::JSON_TABLE_NAME];
}
return $tables;
} | php | {
"resource": ""
} |
q255419 | JsonODataReaderWriter.getEntity | test | public function getEntity(Entity $entity)
{
$entityProperties = $entity->getProperties();
$properties = array();
foreach ($entityProperties as $name => $property) {
$edmType = $property->getEdmType();
$edmValue = $property->getValue();
if (is_null($edmValue)) {
// No @odata.type JSON property needed for null value
$properties[$name] = null;
} else {
if (is_null($edmType)) {
$edmType = EdmType::propertyType($edmValue);
}
$value = EdmType::serializeValue($edmType, $edmValue);
$properties[$name] = $value;
if (EdmType::typeRequired($edmType)) {
$properties[$name . Resources::JSON_ODATA_TYPE_SUFFIX] = $edmType;
}
}
}
return json_encode($properties);
} | php | {
"resource": ""
} |
q255420 | JsonODataReaderWriter.parseEntities | test | public function parseEntities($body)
{
$rawEntities = json_decode($body, true);
$entities = array();
foreach ($rawEntities[Resources::JSON_VALUE] as $rawEntity) {
$entities[] = $this->parseOneEntity($rawEntity);
}
return $entities;
} | php | {
"resource": ""
} |
q255421 | AccessPolicy.setStart | test | public function setStart(\DateTime $start = null)
{
if ($start != null) {
Validate::isDate($start);
}
$this->start = $start;
} | php | {
"resource": ""
} |
q255422 | AccessPolicy.validatePermission | test | private function validatePermission($permission)
{
$validPermissions = static::getResourceValidPermissions();
$result = '';
foreach ($validPermissions as $validPermission) {
if (strpos($permission, $validPermission) !== false) {
//append the valid permission to result.
$result .= $validPermission;
//remove all the character that represents the permission.
$permission = str_replace(
$validPermission,
'',
$permission
);
}
}
//After filtering all the permissions, if there is still characters
//left in the given permission, throw exception.
Validate::isTrue(
$permission == '',
sprintf(
Resources::INVALID_PERMISSION_PROVIDED,
$this->getResourceType(),
implode(', ', $validPermissions)
)
);
return $result;
} | php | {
"resource": ""
} |
q255423 | FileRestProxy.createPath | test | private function createPath($share, $directory = '')
{
if (empty($directory) && ($directory != '0')) {
return empty($share) ? '/' : $share;
}
$encodedFile = urlencode($directory);
// Unencode the forward slashes to match what the server expects.
$encodedFile = str_replace('%2F', '/', $encodedFile);
// Unencode the backward slashes to match what the server expects.
$encodedFile = str_replace('%5C', '/', $encodedFile);
// Re-encode the spaces (encoded as space) to the % encoding.
$encodedFile = str_replace('+', '%20', $encodedFile);
// Empty share means accessing default share
if (empty($share)) {
return $encodedFile;
}
return '/' . $share . '/' . $encodedFile;
} | php | {
"resource": ""
} |
q255424 | FileRestProxy.getSharePropertiesAsyncImpl | test | private function getSharePropertiesAsyncImpl(
$share,
FileServiceOptions $options = null,
$operation = null
) {
Validate::canCastAsString($share, 'share');
Validate::isTrue(
$operation == 'properties' || $operation == 'metadata',
Resources::FILE_SHARE_PROPERTIES_OPERATION_INVALID
);
$method = Resources::HTTP_GET;
$headers = array();
$queryParams = array();
$postParams = array();
$path = $this->createPath($share);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_REST_TYPE,
'share'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
if ($operation == 'metadata') {
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
$operation
);
}
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
)->then(function ($response) {
$responseHeaders = HttpFormatter::formatHeaders($response->getHeaders());
return GetSharePropertiesResult::create($responseHeaders);
}, null);
} | php | {
"resource": ""
} |
q255425 | FileRestProxy.setSharePropertiesAsyncImpl | test | private function setSharePropertiesAsyncImpl(
$share,
array $properties,
FileServiceOptions $options = null,
$operation = 'properties'
) {
Validate::canCastAsString($share, 'share');
Validate::isTrue(
$operation == 'properties' || $operation == 'metadata',
Resources::FILE_SHARE_PROPERTIES_OPERATION_INVALID
);
Validate::canCastAsString($share, 'share');
$headers = array();
if ($operation == 'properties') {
$headers[Resources::X_MS_SHARE_QUOTA] =
$properties[Resources::X_MS_SHARE_QUOTA];
} else {
Utilities::validateMetadata($properties);
$headers = $this->generateMetadataHeaders($properties);
}
$method = Resources::HTTP_PUT;
$postParams = array();
$queryParams = array();
$path = $this->createPath($share);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_REST_TYPE,
'share'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
$operation
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255426 | FileRestProxy.listSharesAsync | test | public function listSharesAsync(ListSharesOptions $options = null)
{
$method = Resources::HTTP_GET;
$headers = array();
$queryParams = array();
$postParams = array();
$path = Resources::EMPTY_STRING;
if (is_null($options)) {
$options = new ListSharesOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'list'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_PREFIX,
$options->getPrefix()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_MARKER,
$options->getNextMarker()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_MAX_RESULTS,
$options->getMaxResults()
);
$isInclude = $options->getIncludeMetadata();
$isInclude = $isInclude ? 'metadata' : null;
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_INCLUDE,
$isInclude
);
$dataSerializer = $this->dataSerializer;
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
)->then(function ($response) use ($dataSerializer) {
$parsed = $dataSerializer->unserialize($response->getBody());
return ListSharesResult::create(
$parsed,
Utilities::getLocationFromHeaders($response->getHeaders())
);
});
} | php | {
"resource": ""
} |
q255427 | FileRestProxy.createShare | test | public function createShare(
$share,
CreateShareOptions $options = null
) {
$this->createShareAsync($share, $options)->wait();
} | php | {
"resource": ""
} |
q255428 | FileRestProxy.createShareAsync | test | public function createShareAsync(
$share,
CreateShareOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::notNullOrEmpty($share, 'share');
$method = Resources::HTTP_PUT;
$postParams = array();
$queryParams = array(Resources::QP_REST_TYPE => 'share');
$path = $this->createPath($share);
if (is_null($options)) {
$options = new CreateShareOptions();
}
$metadata = $options->getMetadata();
$headers = $this->generateMetadataHeaders($metadata);
$this->addOptionalHeader(
$headers,
Resources::X_MS_SHARE_QUOTA,
$options->getQuota()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_CREATED,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255429 | FileRestProxy.deleteShare | test | public function deleteShare(
$share,
FileServiceOptions $options = null
) {
$this->deleteShareAsync($share, $options)->wait();
} | php | {
"resource": ""
} |
q255430 | FileRestProxy.getShareProperties | test | public function getShareProperties(
$share,
FileServiceOptions $options = null
) {
return $this->getSharePropertiesAsync($share, $options)->wait();
} | php | {
"resource": ""
} |
q255431 | FileRestProxy.setShareProperties | test | public function setShareProperties(
$share,
$quota,
FileServiceOptions $options = null
) {
$this->setSharePropertiesAsync($share, $quota, $options)->wait();
} | php | {
"resource": ""
} |
q255432 | FileRestProxy.setSharePropertiesAsync | test | public function setSharePropertiesAsync(
$share,
$quota,
FileServiceOptions $options = null
) {
return $this->setSharePropertiesAsyncImpl(
$share,
[Resources::X_MS_SHARE_QUOTA => $quota],
$options,
'properties'
);
} | php | {
"resource": ""
} |
q255433 | FileRestProxy.getShareMetadata | test | public function getShareMetadata(
$share,
FileServiceOptions $options = null
) {
return $this->getShareMetadataAsync($share, $options)->wait();
} | php | {
"resource": ""
} |
q255434 | FileRestProxy.setShareMetadata | test | public function setShareMetadata(
$share,
array $metadata,
FileServiceOptions $options = null
) {
$this->setShareMetadataAsync($share, $metadata, $options)->wait();
} | php | {
"resource": ""
} |
q255435 | FileRestProxy.setShareMetadataAsync | test | public function setShareMetadataAsync(
$share,
array $metadata,
FileServiceOptions $options = null
) {
return $this->setSharePropertiesAsyncImpl(
$share,
$metadata,
$options,
'metadata'
);
} | php | {
"resource": ""
} |
q255436 | FileRestProxy.setShareAcl | test | public function setShareAcl(
$share,
ShareACL $acl,
FileServiceOptions $options = null
) {
$this->setShareAclAsync($share, $acl, $options)->wait();
} | php | {
"resource": ""
} |
q255437 | FileRestProxy.setShareAclAsync | test | public function setShareAclAsync(
$share,
ShareACL $acl,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::notNullOrEmpty($acl, 'acl');
$method = Resources::HTTP_PUT;
$headers = array();
$postParams = array();
$queryParams = array();
$path = $this->createPath($share);
$body = $acl->toXml($this->dataSerializer);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_REST_TYPE,
'share'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'acl'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_TYPE,
Resources::URL_ENCODED_CONTENT_TYPE
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
$body,
$options
);
} | php | {
"resource": ""
} |
q255438 | FileRestProxy.listDirectoriesAndFiles | test | public function listDirectoriesAndFiles(
$share,
$path = '',
ListDirectoriesAndFilesOptions $options = null
) {
return $this->listDirectoriesAndFilesAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255439 | FileRestProxy.listDirectoriesAndFilesAsync | test | public function listDirectoriesAndFilesAsync(
$share,
$path = '',
ListDirectoriesAndFilesOptions $options = null
) {
Validate::notNull($share, 'share');
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
$method = Resources::HTTP_GET;
$headers = array();
$postParams = array();
$queryParams = array();
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new ListDirectoriesAndFilesOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_REST_TYPE,
'directory'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'list'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_PREFIX,
$options->getPrefix()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_MARKER,
$options->getNextMarker()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_MAX_RESULTS,
$options->getMaxResults()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$dataSerializer = $this->dataSerializer;
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
)->then(function ($response) use ($dataSerializer) {
$parsed = $dataSerializer->unserialize($response->getBody());
return ListDirectoriesAndFilesResult::create(
$parsed,
Utilities::getLocationFromHeaders($response->getHeaders())
);
}, null);
} | php | {
"resource": ""
} |
q255440 | FileRestProxy.createDirectory | test | public function createDirectory(
$share,
$path,
CreateDirectoryOptions $options = null
) {
$this->createDirectoryAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255441 | FileRestProxy.createDirectoryAsync | test | public function createDirectoryAsync(
$share,
$path,
CreateDirectoryOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
Validate::notNullOrEmpty($path, 'path');
$method = Resources::HTTP_PUT;
$postParams = array();
$queryParams = array(Resources::QP_REST_TYPE => 'directory');
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new CreateDirectoryOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$metadata = $options->getMetadata();
$headers = $this->generateMetadataHeaders($metadata);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_CREATED,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255442 | FileRestProxy.deleteDirectory | test | public function deleteDirectory(
$share,
$path,
FileServiceOptions $options = null
) {
$this->deleteDirectoryAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255443 | FileRestProxy.getDirectoryProperties | test | public function getDirectoryProperties(
$share,
$path,
FileServiceOptions $options = null
) {
return $this->getDirectoryPropertiesAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255444 | FileRestProxy.getDirectoryPropertiesAsync | test | public function getDirectoryPropertiesAsync(
$share,
$path,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
$method = Resources::HTTP_GET;
$headers = array();
$postParams = array();
$queryParams = array(Resources::QP_REST_TYPE => 'directory');
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
)->then(function ($response) {
$parsed = HttpFormatter::formatHeaders($response->getHeaders());
return GetDirectoryPropertiesResult::create($parsed);
}, null);
} | php | {
"resource": ""
} |
q255445 | FileRestProxy.getDirectoryMetadata | test | public function getDirectoryMetadata(
$share,
$path,
FileServiceOptions $options = null
) {
return $this->getDirectoryMetadataAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255446 | FileRestProxy.setDirectoryMetadata | test | public function setDirectoryMetadata(
$share,
$path,
array $metadata,
FileServiceOptions $options = null
) {
$this->setDirectoryMetadataAsync(
$share,
$path,
$metadata,
$options
)->wait();
} | php | {
"resource": ""
} |
q255447 | FileRestProxy.createFile | test | public function createFile(
$share,
$path,
$size,
CreateFileOptions $options = null
) {
return $this->createFileAsync(
$share,
$path,
$size,
$options
)->wait();
} | php | {
"resource": ""
} |
q255448 | FileRestProxy.createFileAsync | test | public function createFileAsync(
$share,
$path,
$size,
CreateFileOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::notNullOrEmpty($share, 'share');
Validate::canCastAsString($path, 'path');
Validate::notNullOrEmpty($path, 'path');
Validate::isInteger($size, 'size');
$method = Resources::HTTP_PUT;
$postParams = array();
$queryParams = array();
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new CreateFileOptions();
}
Utilities::validateMetadata($options->getMetadata());
$headers = $this->generateMetadataHeaders($options->getMetadata());
$this->addOptionalHeader(
$headers,
Resources::X_MS_TYPE,
'file'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_CONTENT_LENGTH,
$size
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_TYPE,
$options->getContentType()
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_ENCODING,
$options->getContentEncoding()
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_LANGUAGE,
$options->getContentLanguage()
);
$this->addOptionalHeader(
$headers,
Resources::CACHE_CONTROL,
$options->getCacheControl()
);
$this->addOptionalHeader(
$headers,
Resources::FILE_CONTENT_MD5,
$options->getContentMD5()
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_DISPOSITION,
$options->getContentDisposition()
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_DISPOSITION,
$options->getContentDisposition()
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_CREATED,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255449 | FileRestProxy.deleteFile | test | public function deleteFile(
$share,
$path,
FileServiceOptions $options = null
) {
$this->deleteFileAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255450 | FileRestProxy.deleteFileAsync | test | public function deleteFileAsync(
$share,
$path,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
$method = Resources::HTTP_DELETE;
$headers = array();
$postParams = array();
$queryParams = array();
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_ACCEPTED,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255451 | FileRestProxy.getFile | test | public function getFile(
$share,
$path,
GetFileOptions $options = null
) {
return $this->getFileAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255452 | FileRestProxy.getFileAsync | test | public function getFileAsync(
$share,
$path,
GetFileOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
$method = Resources::HTTP_GET;
$headers = array();
$postParams = array();
$queryParams = array();
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new GetFileOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_RANGE,
$options->getRangeString() == '' ? null : $options->getRangeString()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_RANGE_GET_CONTENT_MD5,
$options->getRangeGetContentMD5() ? 'true' : null
);
$options->setIsStreaming(true);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
array(Resources::STATUS_OK, Resources::STATUS_PARTIAL_CONTENT),
Resources::EMPTY_STRING,
$options
)->then(function ($response) {
$metadata = Utilities::getMetadataArray(
HttpFormatter::formatHeaders($response->getHeaders())
);
return GetFileResult::create(
HttpFormatter::formatHeaders($response->getHeaders()),
$response->getBody(),
$metadata
);
});
} | php | {
"resource": ""
} |
q255453 | FileRestProxy.getFileProperties | test | public function getFileProperties(
$share,
$path,
FileServiceOptions $options = null
) {
return $this->getFilePropertiesAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255454 | FileRestProxy.getFilePropertiesAsync | test | public function getFilePropertiesAsync(
$share,
$path,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
$method = Resources::HTTP_HEAD;
$headers = array();
$queryParams = array();
$postParams = array();
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
)->then(function ($response) {
$parsed = HttpFormatter::formatHeaders($response->getHeaders());
return FileProperties::createFromHttpHeaders($parsed);
}, null);
} | php | {
"resource": ""
} |
q255455 | FileRestProxy.setFileProperties | test | public function setFileProperties(
$share,
$path,
FileProperties $properties,
FileServiceOptions $options = null
) {
$this->setFilePropertiesAsync($share, $path, $properties, $options)->wait();
} | php | {
"resource": ""
} |
q255456 | FileRestProxy.setFilePropertiesAsync | test | public function setFilePropertiesAsync(
$share,
$path,
FileProperties $properties,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
$headers = array();
$method = Resources::HTTP_PUT;
$postParams = array();
$queryParams = array(Resources::QP_COMP => 'properties');
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_CACHE_CONTROL,
$properties->getCacheControl()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_CONTENT_TYPE,
$properties->getContentType()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_CONTENT_MD5,
$properties->getContentMD5()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_CONTENT_ENCODING,
$properties->getContentEncoding()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_CONTENT_LANGUAGE,
$properties->getContentLanguage()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_CONTENT_DISPOSITION,
$properties->getContentDisposition()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_CONTENT_LENGTH,
$properties->getContentLength()
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255457 | FileRestProxy.getFileMetadata | test | public function getFileMetadata(
$share,
$path,
FileServiceOptions $options = null
) {
return $this->getFileMetadataAsync($share, $path, $options)->wait();
} | php | {
"resource": ""
} |
q255458 | FileRestProxy.setFileMetadata | test | public function setFileMetadata(
$share,
$path,
array $metadata,
FileServiceOptions $options = null
) {
return $this->setFileMetadataAsync(
$share,
$path,
$metadata,
$options
)->wait();
} | php | {
"resource": ""
} |
q255459 | FileRestProxy.setFileMetadataAsync | test | public function setFileMetadataAsync(
$share,
$path,
array $metadata,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
$method = Resources::HTTP_PUT;
$postParams = array();
$queryParams = array();
$path = $this->createPath($share, $path);
Utilities::validateMetadata($metadata);
$headers = $this->generateMetadataHeaders($metadata);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'metadata'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255460 | FileRestProxy.putFileRange | test | public function putFileRange(
$share,
$path,
$content,
Range $range,
PutFileRangeOptions $options = null
) {
$this->putFileRangeAsync(
$share,
$path,
$content,
$range,
$options
)->wait();
} | php | {
"resource": ""
} |
q255461 | FileRestProxy.putFileRangeAsync | test | public function putFileRangeAsync(
$share,
$path,
$content,
Range $range,
PutFileRangeOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
Validate::notNullOrEmpty($path, 'path');
Validate::notNullOrEmpty($share, 'share');
Validate::notNull($range->getLength(), Resources::RESOURCE_RANGE_LENGTH_MUST_SET);
$stream = Psr7\stream_for($content);
$method = Resources::HTTP_PUT;
$headers = array();
$queryParams = array();
$postParams = array();
$path = $this->createPath($share, $path);
if ($options == null) {
$options = new PutFileRangeOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_RANGE,
$range->getRangeString()
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_LENGTH,
$range->getLength()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_WRITE,
'Update'
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_MD5,
$options->getContentMD5()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'range'
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_CREATED,
$stream,
$options
);
} | php | {
"resource": ""
} |
q255462 | FileRestProxy.createFileFromContent | test | public function createFileFromContent(
$share,
$path,
$content,
CreateFileFromContentOptions $options = null
) {
$this->createFileFromContentAsync($share, $path, $content, $options)->wait();
} | php | {
"resource": ""
} |
q255463 | FileRestProxy.createFileFromContentAsync | test | public function createFileFromContentAsync(
$share,
$path,
$content,
CreateFileFromContentOptions $options = null
) {
$stream = Psr7\stream_for($content);
$size = $stream->getSize();
if ($options == null) {
$options = new CreateFileFromContentOptions();
}
//create the file first
$promise = $this->createFileAsync($share, $path, $size, $options);
//then upload the content
$range = new Range(0, $size - 1);
$putOptions = new PutFileRangeOptions($options);
$useTransactionalMD5 = $options->getUseTransactionalMD5();
if ($size > Resources::MB_IN_BYTES_4) {
return $promise->then(function ($response) use (
$share,
$path,
$stream,
$range,
$putOptions,
$useTransactionalMD5
) {
return $this->multiplePutRangeConcurrentAsync(
$share,
$path,
$stream,
$range,
$putOptions,
$useTransactionalMD5
);
}, null);
} else {
return $promise->then(function ($response) use (
$share,
$path,
$stream,
$range,
$putOptions
) {
return $this->putFileRangeAsync(
$share,
$path,
$stream,
$range,
$putOptions
);
}, null);
}
} | php | {
"resource": ""
} |
q255464 | FileRestProxy.clearFileRange | test | public function clearFileRange(
$share,
$path,
Range $range,
FileServiceOptions $options = null
) {
$this->clearFileRangeAsync($share, $path, $range, $options)->wait();
} | php | {
"resource": ""
} |
q255465 | FileRestProxy.clearFileRangeAsync | test | public function clearFileRangeAsync(
$share,
$path,
Range $range,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
Validate::notNullOrEmpty($path, 'path');
Validate::notNullOrEmpty($share, 'share');
$method = Resources::HTTP_PUT;
$headers = array();
$queryParams = array();
$postParams = array();
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalHeader(
$headers,
Resources::X_MS_RANGE,
$range->getRangeString()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_WRITE,
'Clear'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'range'
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_CREATED,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255466 | FileRestProxy.listFileRange | test | public function listFileRange(
$share,
$path,
Range $range = null,
FileServiceOptions $options = null
) {
return $this->listFileRangeAsync($share, $path, $range, $options)->wait();
} | php | {
"resource": ""
} |
q255467 | FileRestProxy.listFileRangeAsync | test | public function listFileRangeAsync(
$share,
$path,
Range $range = null,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
Validate::notNullOrEmpty($path, 'path');
Validate::notNullOrEmpty($share, 'share');
$method = Resources::HTTP_GET;
$headers = array();
$queryParams = array();
$postParams = array();
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new FileServiceOptions();
}
if ($range != null) {
$this->addOptionalHeader(
$headers,
Resources::X_MS_RANGE,
$range->getRangeString()
);
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'rangelist'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$dataSerializer = $this->dataSerializer;
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
)->then(function ($response) use ($dataSerializer) {
$responseHeaders = HttpFormatter::formatHeaders($response->getHeaders());
$parsed = $dataSerializer->unserialize($response->getBody());
return ListFileRangesResult::create($responseHeaders, $parsed);
}, null);
} | php | {
"resource": ""
} |
q255468 | FileRestProxy.abortCopy | test | public function abortCopy(
$share,
$path,
$copyID,
FileServiceOptions $options = null
) {
return $this->abortCopyAsync(
$share,
$path,
$copyID,
$options
)->wait();
} | php | {
"resource": ""
} |
q255469 | FileRestProxy.abortCopyAsync | test | public function abortCopyAsync(
$share,
$path,
$copyID,
FileServiceOptions $options = null
) {
Validate::canCastAsString($share, 'share');
Validate::canCastAsString($path, 'path');
Validate::canCastAsString($copyID, 'copyID');
Validate::notNullOrEmpty($share, 'share');
Validate::notNullOrEmpty($path, 'path');
Validate::notNullOrEmpty($copyID, 'copyID');
$method = Resources::HTTP_PUT;
$headers = array();
$postParams = array();
$queryParams = array();
$path = $this->createPath($share, $path);
if (is_null($options)) {
$options = new FileServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_TIMEOUT,
$options->getTimeout()
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'copy'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COPY_ID,
$copyID
);
$this->addOptionalHeader(
$headers,
Resources::X_MS_COPY_ACTION,
'abort'
);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_NO_CONTENT,
Resources::EMPTY_STRING,
$options
);
} | php | {
"resource": ""
} |
q255470 | BatchOperation.setType | test | public function setType($type)
{
Validate::isTrue(
BatchOperationType::isValid($type),
Resources::INVALID_BO_TYPE_MSG
);
$this->_type = $type;
} | php | {
"resource": ""
} |
q255471 | BatchOperation.addParameter | test | public function addParameter($name, $value)
{
Validate::isTrue(
BatchOperationParameterName::isValid($name),
Resources::INVALID_BO_PN_MSG
);
$this->_params[$name] = $value;
} | php | {
"resource": ""
} |
q255472 | BatchResult._constructResponses | test | private static function _constructResponses($body, IMimeReaderWriter $mimeSerializer)
{
$responses = array();
$parts = $mimeSerializer->decodeMimeMultipart($body);
// Decrease the count of parts to remove the batch response body and just
// include change sets response body. We may need to undo this action in
// case that batch response body has useful info.
$count = count($parts);
for ($i = 0; $i < $count; $i++) {
$response = new \stdClass();
// Split lines
$lines = preg_split("/\\r\\n|\\r|\\n/", $parts[$i]);
// Version Status Reason
$statusTokens = explode(' ', $lines[0], 3);
$response->version = $statusTokens[0];
$response->statusCode = $statusTokens[1];
$response->reason = $statusTokens[2];
$headers = array();
$j = 1;
do {
$headerLine = $lines[$j++];
$headerTokens = explode(':', $headerLine);
$headers[trim($headerTokens[0])] =
isset($headerTokens[1]) ? trim($headerTokens[1]) : null;
} while (Resources::EMPTY_STRING != $headerLine);
$response->headers = $headers;
$response->body = implode(PHP_EOL, array_slice($lines, $j));
$responses[] = $response;
}
return $responses;
} | php | {
"resource": ""
} |
q255473 | BatchResult._compareUsingContentId | test | private static function _compareUsingContentId($r1, $r2)
{
$h1 = array_change_key_case($r1->headers);
$h2 = array_change_key_case($r2->headers);
$c1 = Utilities::tryGetValue($h1, Resources::CONTENT_ID, 0);
$c2 = Utilities::tryGetValue($h2, Resources::CONTENT_ID, 0);
return intval($c1) >= intval($c2);
} | php | {
"resource": ""
} |
q255474 | BatchResult.create | test | public static function create(
$body,
array $operations,
array $contexts,
IODataReaderWriter $odataSerializer,
IMimeReaderWriter $mimeSerializer
) {
$result = new BatchResult();
$responses = self::_constructResponses($body, $mimeSerializer);
$callbackName = __CLASS__ . '::_compareUsingContentId';
$count = count($responses);
$entries = array();
// Sort $responses based on Content-ID so they match order of $operations.
uasort($responses, $callbackName);
for ($i = 0; $i < $count; $i++) {
$context = $contexts[$i];
$response = $responses[$i];
$operation = $operations[$i];
$type = $operation->getType();
$body = $response->body;
$headers = HttpFormatter::formatHeaders($response->headers);
//Throw the error directly if error occurs in the batch operation.
ServiceRestProxy::throwIfError(
new Response(
$response->statusCode,
$response->headers,
$response->body,
$response->version,
$response->reason
),
$context->getStatusCodes()
);
switch ($type) {
case BatchOperationType::INSERT_ENTITY_OPERATION:
$entries[] = InsertEntityResult::create(
$body,
$headers,
$odataSerializer
);
break;
case BatchOperationType::UPDATE_ENTITY_OPERATION:
case BatchOperationType::MERGE_ENTITY_OPERATION:
case BatchOperationType::INSERT_REPLACE_ENTITY_OPERATION:
case BatchOperationType::INSERT_MERGE_ENTITY_OPERATION:
$entries[] = UpdateEntityResult::create($headers);
break;
case BatchOperationType::DELETE_ENTITY_OPERATION:
$entries[] = Resources::BATCH_ENTITY_DEL_MSG;
break;
default:
throw new \InvalidArgumentException();
}
}
$result->setEntries($entries);
return $result;
} | php | {
"resource": ""
} |
q255475 | XmlSerializer.getInstanceAttributes | test | private static function getInstanceAttributes($targetObject, array $methodArray)
{
foreach ($methodArray as $method) {
if ($method->name == 'getAttributes') {
$classProperty = $method->invoke($targetObject);
return $classProperty;
}
}
return null;
} | php | {
"resource": ""
} |
q255476 | XmlSerializer.serialize | test | public function serialize(array $array, array $properties = null)
{
$xmlVersion = '1.0';
$xmlEncoding = 'UTF-8';
$standalone = Utilities::tryGetValue($properties, self::STANDALONE);
$defaultTag = Utilities::tryGetValue($properties, self::DEFAULT_TAG);
$rootName = Utilities::tryGetValue($properties, self::ROOT_NAME);
$docNamespace = Utilities::tryGetValue(
$array,
Resources::XTAG_NAMESPACE,
null
);
if (!is_array($array)) {
return false;
}
$xmlw = new \XmlWriter();
$xmlw->openMemory();
$xmlw->setIndent(true);
$xmlw->startDocument($xmlVersion, $xmlEncoding, $standalone);
if (is_null($docNamespace)) {
$xmlw->startElement($rootName);
} else {
foreach ($docNamespace as $uri => $prefix) {
$xmlw->startElementNS($prefix, $rootName, $uri);
break;
}
}
unset($array[Resources::XTAG_NAMESPACE]);
self::arr2xml($xmlw, $array, $defaultTag);
$xmlw->endElement();
return $xmlw->outputMemory(true);
} | php | {
"resource": ""
} |
q255477 | CORS.create | test | public static function create(array $parsedResponse)
{
Validate::hasKey(
Resources::XTAG_ALLOWED_ORIGINS,
'parsedResponse',
$parsedResponse
);
Validate::hasKey(
Resources::XTAG_ALLOWED_METHODS,
'parsedResponse',
$parsedResponse
);
Validate::hasKey(
Resources::XTAG_ALLOWED_HEADERS,
'parsedResponse',
$parsedResponse
);
Validate::hasKey(
Resources::XTAG_EXPOSED_HEADERS,
'parsedResponse',
$parsedResponse
);
Validate::hasKey(
Resources::XTAG_MAX_AGE_IN_SECONDS,
'parsedResponse',
$parsedResponse
);
// Get the values from the parsed response.
$allowedOrigins = array_filter(explode(
',',
$parsedResponse[Resources::XTAG_ALLOWED_ORIGINS]
));
$allowedMethods = array_filter(explode(
',',
$parsedResponse[Resources::XTAG_ALLOWED_METHODS]
));
$allowedHeaders = array_filter(explode(
',',
$parsedResponse[Resources::XTAG_ALLOWED_HEADERS]
));
$exposedHeaders = array_filter(explode(
',',
$parsedResponse[Resources::XTAG_EXPOSED_HEADERS]
));
$maxAgeInSeconds = intval(
$parsedResponse[Resources::XTAG_MAX_AGE_IN_SECONDS]
);
return new CORS(
$allowedOrigins,
$allowedMethods,
$allowedHeaders,
$exposedHeaders,
$maxAgeInSeconds
);
} | php | {
"resource": ""
} |
q255478 | ServiceRestTrait.getServicePropertiesAsync | test | public function getServicePropertiesAsync(
ServiceOptions $options = null
) {
$method = Resources::HTTP_GET;
$headers = array();
$queryParams = array();
$postParams = array();
$path = Resources::EMPTY_STRING;
if (is_null($options)) {
$options = new ServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_REST_TYPE,
'service'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'properties'
);
$dataSerializer = $this->dataSerializer;
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
)->then(function ($response) use ($dataSerializer) {
$parsed = $dataSerializer->unserialize($response->getBody());
return GetServicePropertiesResult::create($parsed);
}, null);
} | php | {
"resource": ""
} |
q255479 | ServiceRestTrait.setServiceProperties | test | public function setServiceProperties(
ServiceProperties $serviceProperties,
ServiceOptions $options = null
) {
$this->setServicePropertiesAsync($serviceProperties, $options)->wait();
} | php | {
"resource": ""
} |
q255480 | ServiceRestTrait.setServicePropertiesAsync | test | public function setServicePropertiesAsync(
ServiceProperties $serviceProperties,
ServiceOptions $options = null
) {
Validate::isTrue(
$serviceProperties instanceof ServiceProperties,
Resources::INVALID_SVC_PROP_MSG
);
$method = Resources::HTTP_PUT;
$headers = array();
$queryParams = array();
$postParams = array();
$path = Resources::EMPTY_STRING;
$body = $serviceProperties->toXml($this->dataSerializer);
if (is_null($options)) {
$options = new ServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_REST_TYPE,
'service'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'properties'
);
$this->addOptionalHeader(
$headers,
Resources::CONTENT_TYPE,
Resources::URL_ENCODED_CONTENT_TYPE
);
$options->setLocationMode(LocationMode::PRIMARY_ONLY);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_ACCEPTED,
$body,
$options
);
} | php | {
"resource": ""
} |
q255481 | ServiceRestTrait.getServiceStatsAsync | test | public function getServiceStatsAsync(ServiceOptions $options = null)
{
$method = Resources::HTTP_GET;
$headers = array();
$queryParams = array();
$postParams = array();
$path = Resources::EMPTY_STRING;
if (is_null($options)) {
$options = new ServiceOptions();
}
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_REST_TYPE,
'service'
);
$this->addOptionalQueryParam(
$queryParams,
Resources::QP_COMP,
'stats'
);
$dataSerializer = $this->dataSerializer;
$options->setLocationMode(LocationMode::SECONDARY_ONLY);
return $this->sendAsync(
$method,
$headers,
$queryParams,
$postParams,
$path,
Resources::STATUS_OK,
Resources::EMPTY_STRING,
$options
)->then(function ($response) use ($dataSerializer) {
$parsed = $dataSerializer->unserialize($response->getBody());
return GetServiceStatsResult::create($parsed);
}, null);
} | php | {
"resource": ""
} |
q255482 | ListQueuesResult.create | test | public static function create(array $parsedResponse, $location = '')
{
$result = new ListQueuesResult();
$serviceEndpoint = Utilities::tryGetKeysChainValue(
$parsedResponse,
Resources::XTAG_ATTRIBUTES,
Resources::XTAG_SERVICE_ENDPOINT
);
$result->setAccountName(Utilities::tryParseAccountNameFromUrl(
$serviceEndpoint
));
$result->setPrefix(Utilities::tryGetValue(
$parsedResponse,
Resources::QP_PREFIX
));
$result->setMarker(Utilities::tryGetValue(
$parsedResponse,
Resources::QP_MARKER
));
$nextMarker = Utilities::tryGetValue($parsedResponse, Resources::QP_NEXT_MARKER);
if ($nextMarker != null) {
$result->setContinuationToken(
new MarkerContinuationToken(
$nextMarker,
$location
)
);
}
$result->setMaxResults(Utilities::tryGetValue(
$parsedResponse,
Resources::QP_MAX_RESULTS
));
$queues = array();
$rawQueues = array();
if (!empty($parsedResponse['Queues'])) {
$rawQueues = Utilities::getArray($parsedResponse['Queues']['Queue']);
}
foreach ($rawQueues as $value) {
$queue = new Queue($value['Name'], $serviceEndpoint . $value['Name']);
$metadata = Utilities::tryGetValue($value, Resources::QP_METADATA);
$queue->setMetadata(is_null($metadata) ? array() : $metadata);
$queues[] = $queue;
}
$result->setQueues($queues);
return $result;
} | php | {
"resource": ""
} |
q255483 | ListQueuesResult.setQueues | test | protected function setQueues(array $queues)
{
$this->_queues = array();
foreach ($queues as $queue) {
$this->_queues[] = clone $queue;
}
} | php | {
"resource": ""
} |
q255484 | Utilities.tryGetSecondaryEndpointFromPrimaryEndpoint | test | public static function tryGetSecondaryEndpointFromPrimaryEndpoint($uri)
{
$splitTokens = explode('.', $uri);
if (count($splitTokens) > 0 && $splitTokens[0] != '') {
$schemaAccountToken = $splitTokens[0];
$schemaAccountSplitTokens = explode('/', $schemaAccountToken);
if (count($schemaAccountSplitTokens) > 0 &&
$schemaAccountSplitTokens[0] != '') {
$accountName = $schemaAccountSplitTokens[
count($schemaAccountSplitTokens) - 1
];
$schemaAccountSplitTokens[count($schemaAccountSplitTokens) - 1] =
$accountName . Resources::SECONDARY_STRING;
$splitTokens[0] = implode('/', $schemaAccountSplitTokens);
$secondaryUri = implode('.', $splitTokens);
return $secondaryUri;
}
}
return null;
} | php | {
"resource": ""
} |
q255485 | Utilities.serialize | test | public static function serialize(
array $array,
$rootName,
$defaultTag = null,
$standalone = null
) {
$xmlVersion = '1.0';
$xmlEncoding = 'UTF-8';
if (!is_array($array)) {
return false;
}
$xmlw = new \XmlWriter();
$xmlw->openMemory();
$xmlw->startDocument($xmlVersion, $xmlEncoding, $standalone);
$xmlw->startElement($rootName);
self::_arr2xml($xmlw, $array, $defaultTag);
$xmlw->endElement();
return $xmlw->outputMemory(true);
} | php | {
"resource": ""
} |
q255486 | Utilities.toBoolean | test | public static function toBoolean($obj, $skipNull = false)
{
if ($skipNull && is_null($obj)) {
return null;
}
return filter_var($obj, FILTER_VALIDATE_BOOLEAN);
} | php | {
"resource": ""
} |
q255487 | Utilities.rfc1123ToDateTime | test | public static function rfc1123ToDateTime($date)
{
$timeZone = new \DateTimeZone('GMT');
$format = Resources::AZURE_DATE_FORMAT;
return \DateTime::createFromFormat($format, $date, $timeZone);
} | php | {
"resource": ""
} |
q255488 | Utilities.isoDate | test | public static function isoDate(\DateTimeInterface $date)
{
$date = clone $date;
$date = $date->setTimezone(new \DateTimeZone('UTC'));
return str_replace('+00:00', 'Z', $date->format('c'));
} | php | {
"resource": ""
} |
q255489 | Utilities.convertToDateTime | test | public static function convertToDateTime($value)
{
if ($value instanceof \DateTime) {
return $value;
}
if (substr($value, -1) == 'Z') {
$value = substr($value, 0, strlen($value) - 1);
}
return new \DateTime($value, new \DateTimeZone('UTC'));
} | php | {
"resource": ""
} |
q255490 | Utilities.base256ToDec | test | public static function base256ToDec($number)
{
Validate::canCastAsString($number, 'number');
$result = 0;
$base = 1;
for ($i = strlen($number) - 1; $i >= 0; $i--) {
$result = bcadd($result, bcmul(ord($number[$i]), $base));
$base = bcmul($base, 256);
}
return $result;
} | php | {
"resource": ""
} |
q255491 | Utilities.allZero | test | public static function allZero($content)
{
$size = strlen($content);
// If all Zero, skip this range
for ($i = 0; $i < $size; $i++) {
if (ord($content[$i]) != 0) {
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q255492 | Utilities.appendDelimiter | test | public static function appendDelimiter($string, $delimiter)
{
if (!self::endsWith($string, $delimiter)) {
$string .= $delimiter;
}
return $string;
} | php | {
"resource": ""
} |
q255493 | Utilities.requestSentToSecondary | test | public static function requestSentToSecondary(
\Psr\Http\Message\RequestInterface $request,
array $options
) {
$uri = $request->getUri();
$secondaryUri = $options[Resources::ROS_SECONDARY_URI];
$isSecondary = false;
if (strpos((string)$uri, (string)$secondaryUri) !== false) {
$isSecondary = true;
}
return $isSecondary;
} | php | {
"resource": ""
} |
q255494 | Utilities.getLocationFromHeaders | test | public static function getLocationFromHeaders(array $headers)
{
$value = Utilities::tryGetValue(
$headers,
Resources::X_MS_CONTINUATION_LOCATION_MODE
);
$result = '';
if (\is_string($value)) {
$result = $value;
} elseif (!empty($value)) {
$result = $value[0];
}
return $result;
} | php | {
"resource": ""
} |
q255495 | Utilities.calculateContentMD5 | test | public static function calculateContentMD5($content)
{
Validate::notNull($content, 'content');
Validate::canCastAsString($content, 'content');
return base64_encode(md5($content, true));
} | php | {
"resource": ""
} |
q255496 | ShareACL.validateResourceType | test | protected static function validateResourceType($resourceType)
{
Validate::isTrue(
$resourceType == Resources::RESOURCE_TYPE_SHARE ||
$resourceType == Resources::RESOURCE_TYPE_FILE,
Resources::INVALID_RESOURCE_TYPE
);
} | php | {
"resource": ""
} |
q255497 | UpdateMessageResult.create | test | public static function create(array $headers)
{
$result = new UpdateMessageResult();
$result->setPopReceipt(Utilities::tryGetValueInsensitive(
Resources::X_MS_POPRECEIPT,
$headers
));
$timeNextVisible = Utilities::tryGetValueInsensitive(
Resources::X_MS_TIME_NEXT_VISIBLE,
$headers
);
$date = Utilities::rfc1123ToDateTime($timeNextVisible);
$result->setTimeNextVisible($date);
return $result;
} | php | {
"resource": ""
} |
q255498 | RetryMiddlewareFactory.create | test | public static function create(
$type = self::GENERAL_RETRY_TYPE,
$numberOfRetries = Resources::DEFAULT_NUMBER_OF_RETRIES,
$interval = Resources::DEFAULT_RETRY_INTERVAL,
$accumulationMethod = self::LINEAR_INTERVAL_ACCUMULATION,
$retryConnect = false
) {
//Validate the input parameters
//type
Validate::isTrue(
$type == self::GENERAL_RETRY_TYPE ||
$type == self::APPEND_BLOB_RETRY_TYPE,
sprintf(
Resources::INVALID_PARAM_GENERAL,
'type'
)
);
//numberOfRetries
Validate::isTrue(
$numberOfRetries > 0,
sprintf(
Resources::INVALID_NEGATIVE_PARAM,
'numberOfRetries'
)
);
//interval
Validate::isTrue(
$interval > 0,
sprintf(
Resources::INVALID_NEGATIVE_PARAM,
'interval'
)
);
//accumulationMethod
Validate::isTrue(
$accumulationMethod == self::LINEAR_INTERVAL_ACCUMULATION ||
$accumulationMethod == self::EXPONENTIAL_INTERVAL_ACCUMULATION,
sprintf(
Resources::INVALID_PARAM_GENERAL,
'accumulationMethod'
)
);
//retryConnect
Validate::isBoolean($retryConnect);
//Get the interval calculator according to the type of the
//accumulation method.
$intervalCalculator =
$accumulationMethod == self::LINEAR_INTERVAL_ACCUMULATION ?
self::createLinearDelayCalculator($interval) :
self::createExponentialDelayCalculator($interval);
//Get the retry decider according to the type of the retry and
//the number of retries.
$retryDecider = self::createRetryDecider($type, $numberOfRetries, $retryConnect);
//construct the retry middle ware.
return new RetryMiddleware($intervalCalculator, $retryDecider);
} | php | {
"resource": ""
} |
q255499 | RetryMiddlewareFactory.createRetryDecider | test | protected static function createRetryDecider($type, $maxRetries, $retryConnect)
{
return function (
$retries,
$request,
$response = null,
$exception = null,
$isSecondary = false
) use (
$type,
$maxRetries,
$retryConnect
) {
//Exceeds the retry limit. No retry.
if ($retries >= $maxRetries) {
return false;
}
if (!$response) {
if (!$exception || !($exception instanceof RequestException)) {
return false;
} elseif ($exception instanceof ConnectException) {
return $retryConnect;
} else {
$response = $exception->getResponse();
}
}
if ($type == self::GENERAL_RETRY_TYPE) {
return self::generalRetryDecider(
$response->getStatusCode(),
$isSecondary
);
} else {
return self::appendBlobRetryDecider(
$response->getStatusCode(),
$isSecondary
);
}
return true;
};
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.