cloudinary / permissions
拥有权限API访问权限的账户可以管理自定义权限策略。这些策略为某个主体分配权限,允许该主体在特定范围内(您的账户或产品环境)对指定的资源执行特定操作。请参阅[权限API
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.4.5
- guzzlehttp/psr7: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- overtrue/phplint: ^9.0
- phpunit/phpunit: ^9.0
README
拥有权限API访问权限的账户可以管理自定义权限策略。这些策略为某个主体分配权限,允许该主体在特定范围内(您的账户或产品环境)对指定的资源执行特定操作。
有关在policy_statement
中指定什么以控制Cloudinary活动的说明,请参阅[权限API指南](https://github.com/cloudinary/permissions-php/blob/HEAD/permissions_api_guide),以及定义主体、操作和资源可能值的Cedar模式。
API使用HTTPS上的基本认证。您的配置密钥和配置密钥用于认证。这些凭证(以及您的ACCOUNT_ID)位于Cloudinary控制台的设置 > 账户 > 配置API访问下。
以下语言有专门的SDK
- JavaScript
- PHP
- Java
有关更多信息,请访问https://support.cloudinary.com。
安装和用法
要求
PHP 8.1及更高版本。
Composer
要使用Composer安装绑定,请将以下内容添加到composer.json
{ "require": { "cloudinary/permissions": "*" } }
然后运行composer install
手动安装
下载文件并包含autoload.php
<?php require_once('/path/to/permissions/vendor/autoload.php');
配置
API使用HTTPS上的基本认证。
您的Cloudinary 账户ID、配置密钥和配置密钥用于认证。
这些ID位于Cloudinary控制台下的设置 > 账户 > 配置API访问,或可以从您的Cloudinary控制台上的配置环境变量获取(在仪表板上)。
(格式:CLOUDINARY_ACCOUNT_URL=account://<PROVISIONING_KEY>:<PROVISIONING_SECRET>@<ACCOUNT_ID>
)。
您可以通过每个$apiInstance
初始化传递配置
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure Cloudinary Account URL $config = Cloudinary\Permissions\Configuration::getDefaultConfiguration() ->setCloudinaryAccountUrl('account://provisioning_key:provisioning_secret@account_id'); $apiInstance = new Cloudinary\Permissions\Api\CustomPoliciesApi(null, $config);
或全局设置环境变量。
例如,要设置临时环境变量
-
在Mac或Linux上
export CLOUDINARY_ACCOUNT_URL=account://provisioning_key:provisioning_secret@account_id
-
在Windows上
set CLOUDINARY_ACCOUNT_URL=account://provisioning_key:provisioning_secret@account_id
然后您可以直接初始化$apiInstance
如下
<?php require_once(__DIR__ . '/vendor/autoload.php'); $apiInstance = new Cloudinary\Permissions\Api\CustomPoliciesApi();
入门
请按照安装过程进行操作,然后运行以下命令
<?php require_once(__DIR__ . '/vendor/autoload.php'); $apiInstance = new Cloudinary\Permissions\Api\CustomPoliciesApi(); $scopeType = "'scopeType_example'"; // string | Specifies the level for retrieving policies, either at the account level or within product environments. $scopeId = "'scopeId_example'"; // string | The ID of a specific product environment where the policy is applied. This parameter is only relevant if `scope_type` is \"prodenv\". Find your product environment IDs in the [Product Environments](https://console.cloudinary.com/settings/product-environments) page of the Console Settings. - <product_environment_id> $enabled = true; // bool | Filter policies by enabled status (true/false). $cursor = "'cursor_example'"; // string | A pagination cursor for fetching subsequent results. try { $result = $apiInstance->getCustomPolicies($scopeType, $scopeId, $enabled, $cursor); print_r($result); } catch (Exception $e) { echo 'Exception when calling CustomPoliciesApi->getCustomPolicies: ', $e->getMessage(), PHP_EOL; }
API端点
所有URI都是相对于https://api.cloudinary.com/v2/accounts/ACCOUNT_ID/permissions的,除非操作定义了另一个基本路径。
模型
- CreateCustomPolicy
- CustomPoliciesResponse
- CustomPolicy
- CustomPolicyResponse
- CustomPolicyResponseData
- Error
- ErrorResponse
- UpdateCustomPolicy
授权
basicAuth
- 类型:HTTP基本认证
测试
要运行测试,使用
composer install vendor/bin/phpunit
作者
关于此包
此Cloudinary账户权限API PHP包是自动生成的。
- 包版本:
1.0.0
- API版本:
1.0.4
- 构建包:
org.openapitools.codegen.languages.PhpNextgenClientCodegen