keboola / azure-api-client
Keboola Azure API 客户端
1.0.0
2023-02-22 08:30 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.5
- monolog/monolog: ^2.0|^3.0
- symfony/validator: ^5.0|^6.0
Requires (Dev)
- infection/infection: ^0.26.18
- keboola/coding-standard: ^14.0
- phpstan/phpstan: ^1.9
- phpstan/phpstan-phpunit: ^1.3
- sempro/phpunit-pretty-print: ^1.4
- symfony/http-client: ^6.2
- dev-main
- 1.0.0
- dev-erik-PST-2051
- dev-erik-PST-850-part2
- dev-odin-PST-1670
- dev-pepa_PST-777_tableIngoGenerator
- dev-pepa_auth_adminToken
- dev-pepa_k8s_deployment
- dev-roman-pst-1710
- dev-rrik-om-ci-fixup
- dev-erik-GCP-374-part1
- dev-erik-GCP-374-part3
- dev-erik-GCP-472
- dev-odin-GCP-374-c
- dev-zajca-event-grid
- dev-pepa_azClientNamedArgs
- dev-azure-event-grid
- dev-erik-PST-780-pokuse
This package is auto-updated.
Last update: 2024-09-20 10:14:06 UTC
README
安装
composer require keboola/azure-api-client
用法
使用 API 客户端的最简单方法是创建其实例。
use Keboola\AzureApiClient\ApiClientConfiguration; use Keboola\AzureApiClient\Marketplace\MarketplaceApiClient; use Monolog\Logger; $logger = new Logger('azure-api-client'); $marketplaces = new MarketplaceApiClient(new ClientCredentialsAuth( logger: $logger, ));
认证
默认情况下,API 客户端将尝试使用 ENV 变量 AZURE_TENANT_ID
、AZURE_CLIENT_ID
和 AZURE_CLIENT_SECRET
进行认证。如果其中某些不可用,它将回退到 Azure 元数据 API。
如果您想提供自己的凭据,可以在客户端选项中传递自定义认证器实例
use Keboola\AzureApiClient\ApiClientConfiguration; use Keboola\AzureApiClient\Authentication\Authenticator\ClientCredentialsAuth; use Keboola\AzureApiClient\Marketplace\MarketplaceApiClient; $marketplaces = new MarketplaceApiClient(new ApiClientConfiguration( authenticator: new ClientCredentialsAuth( 'tenant-id', 'client-id', 'client-secret', ), ));
或者直接提供自定义认证令牌
use Keboola\AzureApiClient\ApiClientConfiguration; use Keboola\AzureApiClient\Authentication\Authenticator\StaticBearerTokenAuth; use Keboola\AzureApiClient\Marketplace\MarketplaceApiClient; $marketplaces = new MarketplaceApiClient(new ApiClientConfiguration( authenticator: new StaticBearerTokenAuth('my-token'), ));
或者如果需要,甚至可以使用自定义认证头
use Keboola\AzureApiClient\ApiClientConfiguration; use Keboola\AzureApiClient\Authentication\Authenticator\StaticBearerTokenAuth; use Keboola\AzureApiClient\Marketplace\MarketplaceApiClient; $marketplaces = new MarketplaceApiClient(new ApiClientConfiguration( authenticator: new CustomHeaderAuth('aeg-sas-key', 'XXXXXXXXXXXXXXXXXX0GXXX/nDT4hgdEj9DpBeRr38arnnm5OFg=='), ));
如果这仍然不足以满足您的用例,您可以实现自己的 Keboola\AzureApiClient\Authentication\Authenticator\RequestAuthenticatorFactoryInterface
并将其作为 authenticator
传递。
许可
MIT 许可,请参阅 LICENSE 文件。