keboola / azure-api-client
Keboola Azure API client
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-850-part2
- dev-odin-PST-1670
- dev-pepa_auth_adminToken
- dev-pepa_k8s_deployment
- dev-revert-325-revert-320-erik-PST-2051
- 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-10-25 12:06:53 UTC
README
Installation
composer require keboola/azure-api-client
Usage
The simplest way to use API client is just by creating its instance.
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, ));
Authentication
By default, API client will try to authenticate using ENV variables AZURE_TENANT_ID
, AZURE_CLIENT_ID
and
AZURE_CLIENT_SECRET
. If some of them is not available, it'll fall back to Azure metadata API.
If you want to supply your own credentials, you can pass custom authenticator instance in the client options:
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', ), ));
Or can provide custom authentication token directly:
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'), ));
Or even use custom authentication header if needed:
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=='), ));
If even this is not enough for your use-case, you can implement your own
Keboola\AzureApiClient\Authentication\Authenticator\RequestAuthenticatorFactoryInterface
and pass it as authenticator
.
License
MIT licensed, see LICENSE file.