-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source code copied from azure-storage-php for v1.0.0-common release
- Loading branch information
Showing
56 changed files
with
10,394 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Tracking Breaking changes in 1.0.0 | ||
|
||
* Removed `ServiceBuilder.php`, moved static builder methods into `BlobRestProxy`, `TableRestProxy`, `QueueRestProxy` and `FileRestProxy`. | ||
* Moved method `SharedAccessSignatureHelper::generateBlobServiceSharedAccessSignatureToken()` into `BlobSharedAccessSignatureHelper`. | ||
* Moved method `SharedAccessSignatureHelper::generateTableServiceSharedAccessSignatureToken()` into `TableSharedAccessSignatureHelper`. | ||
* Moved method `SharedAccessSignatureHelper::generateQueueServiceSharedAccessSignatureToken()` into `QueueSharedAccessSignatureHelper`. | ||
* Moved method `SharedAccessSignatureHelper::generateFileServiceSharedAccessSignatureToken()` into `FileSharedAccessSignatureHelper`. | ||
* `CommonMiddleWare` constructor requires storage service version as parameter now. | ||
* `AccessPolicy` class is now an abstract class, added children classes `BlobAccessPolicy`, `ContainerAccessPolicy`, `TableAccessPolicy`, `QueueAccessPolicy`, `FileAccessPolicy` and `ShareAccessPolicy`. | ||
* Deprecated PHP 5.5 support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This [repository](https://github.com/azure/azure-storage-common-php) is currently used for releasing only, please go to [azure-storage-php](https://github.com/azure/azure-storage-php) for submitting issues or contribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
2018.01 - version 1.0.0 | ||
|
||
* Removed `ServiceBuilder.php`, moved static builder methods into `BlobRestProxy`, `TableRestProxy`, `QueueRestProxy` and `FileRestProxy`. | ||
* Moved method `SharedAccessSignatureHelper::generateBlobServiceSharedAccessSignatureToken()` into `BlobSharedAccessSignatureHelper`. | ||
* Moved method `SharedAccessSignatureHelper::generateTableServiceSharedAccessSignatureToken()` into `TableSharedAccessSignatureHelper`. | ||
* Moved method `SharedAccessSignatureHelper::generateQueueServiceSharedAccessSignatureToken()` into `QueueSharedAccessSignatureHelper`. | ||
* Moved method `SharedAccessSignatureHelper::generateFileServiceSharedAccessSignatureToken()` into `FileSharedAccessSignatureHelper`. | ||
* `CommonMiddleWare` constructor requires storage service version as parameter now. | ||
* `AccessPolicy` class is now an abstract class, added children classes `BlobAccessPolicy`, `ContainerAccessPolicy`, `TableAccessPolicy`, `QueueAccessPolicy`, `FileAccessPolicy` and `ShareAccessPolicy`. | ||
* Fixed a bug that `Utilities::allZero()` will return true for non-zero data chunks. | ||
* Deprecated PHP 5.5 support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
MIT License | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Copyright (c) 2016 Microsoft Corporation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
# Microsoft Azure Storage Common PHP Client Library | ||
|
||
# Contributing | ||
This project provides a set of common PHP code shared by Azure Storage Blob, Table, Queue and File PHP client libraries. For how to access Microsoft Azure Storage services (blobs, tables, queues and files), please refer to the [Microsoft Azure Storage PHP Client Library](https://github.com/Azure/azure-storage-php). For documentation on how to host PHP applications on Microsoft Azure, please see the [Microsoft Azure PHP Developer Center](http://www.windowsazure.com/en-us/develop/php/). | ||
|
||
This project welcomes contributions and suggestions. Most contributions require you to agree to a | ||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us | ||
the rights to use your contribution. For details, visit https://cla.microsoft.com. | ||
[![Latest Stable Version](https://poser.pugx.org/microsoft/azure-storage-common/v/stable)](https://packagist.org/packages/microsoft/azure-storage-common) | ||
|
||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide | ||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions | ||
provided by the bot. You will only need to do this once across all repos using our CLA. | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or | ||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. | ||
> **Note** | ||
> | ||
> * This [repository](https://github.com/azure/azure-storage-common-php) is currently used for releasing only, please go to [azure-storage-php](https://github.com/azure/azure-storage-php) for submitting issues or contribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "microsoft/azure-storage-common", | ||
"version": "1.0.0", | ||
"description": "This project provides a set of common code shared by Azure Storage Blob, Table, Queue and File PHP client libraries.", | ||
"keywords": [ "php", "azure", "storage", "sdk", "common" ], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Azure Storage PHP Client Library", | ||
"email": "dmsh@microsoft.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.6.0", | ||
"guzzlehttp/guzzle": "~6.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MicrosoftAzure\\Storage\\Common\\": "src/Common" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<?php | ||
|
||
/** | ||
* LICENSE: The MIT License (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* https://github.com/azure/azure-storage-php/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* PHP version 5 | ||
* | ||
* @category Microsoft | ||
* @package MicrosoftAzure\Storage\Common | ||
* @author Azure Storage PHP SDK <dmsh@microsoft.com> | ||
* @copyright 2016 Microsoft Corporation | ||
* @license https://github.com/azure/azure-storage-php/LICENSE | ||
* @link https://github.com/azure/azure-storage-php | ||
*/ | ||
|
||
namespace MicrosoftAzure\Storage\Common; | ||
|
||
use MicrosoftAzure\Storage\Common\Internal\Utilities; | ||
use MicrosoftAzure\Storage\Common\Internal\Validate; | ||
use MicrosoftAzure\Storage\Common\Internal\ConnectionStringSource; | ||
|
||
/** | ||
* Configuration manager for accessing Windows Azure settings. | ||
* | ||
* @category Microsoft | ||
* @package MicrosoftAzure\Storage\Common | ||
* @author Azure Storage PHP SDK <dmsh@microsoft.com> | ||
* @copyright 2016 Microsoft Corporation | ||
* @license https://github.com/azure/azure-storage-php/LICENSE | ||
* @link https://github.com/azure/azure-storage-php | ||
*/ | ||
class CloudConfigurationManager | ||
{ | ||
private static $_isInitialized = false; | ||
private static $_sources; | ||
|
||
/** | ||
* Restrict users from creating instances from this class | ||
*/ | ||
private function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Initializes the connection string source providers. | ||
* | ||
* @return void | ||
*/ | ||
private static function _init() | ||
{ | ||
if (!self::$_isInitialized) { | ||
self::$_sources = array(); | ||
|
||
// Get list of default connection string sources. | ||
$default = ConnectionStringSource::getDefaultSources(); | ||
foreach ($default as $name => $provider) { | ||
self::$_sources[$name] = $provider; | ||
} | ||
|
||
self::$_isInitialized = true; | ||
} | ||
} | ||
|
||
/** | ||
* Gets a connection string from all available sources. | ||
* | ||
* @param string $key The connection string key name. | ||
* | ||
* @return string If the key does not exist return null. | ||
*/ | ||
public static function getConnectionString($key) | ||
{ | ||
Validate::canCastAsString($key, 'key'); | ||
|
||
self::_init(); | ||
$value = null; | ||
|
||
foreach (self::$_sources as $source) { | ||
$value = call_user_func_array($source, array($key)); | ||
|
||
if (!empty($value)) { | ||
break; | ||
} | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
/** | ||
* Registers a new connection string source provider. If the source to get | ||
* registered is a default source, only the name of the source is required. | ||
* | ||
* @param string $name The source name. | ||
* @param callable $provider The source callback. | ||
* @param boolean $prepend When true, the $provider is processed first when | ||
* calling getConnectionString. When false (the default) the $provider is | ||
* processed after the existing callbacks. | ||
* | ||
* @return void | ||
*/ | ||
public static function registerSource($name, $provider = null, $prepend = false) | ||
{ | ||
Validate::canCastAsString($name, 'name'); | ||
Validate::notNullOrEmpty($name, 'name'); | ||
|
||
self::_init(); | ||
$default = ConnectionStringSource::getDefaultSources(); | ||
|
||
// Try to get callback if the user is trying to register a default source. | ||
$provider = Utilities::tryGetValue($default, $name, $provider); | ||
|
||
Validate::notNullOrEmpty($provider, 'callback'); | ||
|
||
if ($prepend) { | ||
self::$_sources = array_merge( | ||
array($name => $provider), | ||
self::$_sources | ||
); | ||
} else { | ||
self::$_sources[$name] = $provider; | ||
} | ||
} | ||
|
||
/** | ||
* Unregisters a connection string source. | ||
* | ||
* @param string $name The source name. | ||
* | ||
* @return callable | ||
*/ | ||
public static function unregisterSource($name) | ||
{ | ||
Validate::canCastAsString($name, 'name'); | ||
Validate::notNullOrEmpty($name, 'name'); | ||
|
||
self::_init(); | ||
|
||
$sourceCallback = Utilities::tryGetValue(self::$_sources, $name); | ||
|
||
if (!is_null($sourceCallback)) { | ||
unset(self::$_sources[$name]); | ||
} | ||
|
||
return $sourceCallback; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* LICENSE: The MIT License (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* https://github.com/azure/azure-storage-php/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* PHP version 5 | ||
* | ||
* @category Microsoft | ||
* @package MicrosoftAzure\Storage\Common\Exceptions | ||
* @author Azure Storage PHP SDK <dmsh@microsoft.com> | ||
* @copyright 2016 Microsoft Corporation | ||
* @license https://github.com/azure/azure-storage-php/LICENSE | ||
* @link https://github.com/azure/azure-storage-php | ||
*/ | ||
|
||
namespace MicrosoftAzure\Storage\Common\Exceptions; | ||
|
||
use MicrosoftAzure\Storage\Common\Internal\Resources; | ||
|
||
/** | ||
* Exception thrown if an argument type does not match with the expected type. | ||
* | ||
* @category Microsoft | ||
* @package MicrosoftAzure\Storage\Common\Exceptions | ||
* @author Azure Storage PHP SDK <dmsh@microsoft.com> | ||
* @copyright 2016 Microsoft Corporation | ||
* @license https://github.com/azure/azure-storage-php/LICENSE | ||
* @link https://github.com/azure/azure-storage-php | ||
*/ | ||
class InvalidArgumentTypeException extends \InvalidArgumentException | ||
{ | ||
/** | ||
* Constructor. | ||
* | ||
* @param string $validType The valid type that should be provided by the user. | ||
* @param string $name The parameter name. | ||
* | ||
* @return InvalidArgumentTypeException | ||
*/ | ||
public function __construct($validType, $name = null) | ||
{ | ||
parent::__construct( | ||
sprintf(Resources::INVALID_PARAM_MSG, $name, $validType) | ||
); | ||
} | ||
} |
Oops, something went wrong.