PHP Class Scalr\Service\Azure

Since: 5.8.6
Author: Vlad Dobrovolskiy ([email protected])
Show file Open project: scalr/scalr Class Usage Examples

Public Methods

Method Description
__construct ( string $appClientId, string $appSecretKey, string $tenantName ) Constructor.
__get ( string $name ) : Scalr\Service\Azure\AbstractService Magic getter.
assignContributorRoleToApp ( string $subscriptionId, string $roleAssignmentId, string $appObjectId, string $contributorRoleId ) : Scalr\Service\Azure\DataType\RoleAssignmentData Assign Contributor Role Id to specified app.
deleteRoleAssignment ( string $subscriptionId, string $roleAssignmentId ) : boolean Delete role assignment.
getAccessToken ( ) : object Gets Access Token.
getAccessTokenByAuthCode ( string $authorizationCode ) : object Receive access token from server using Authorisation Code.
getAppObjectId ( ) : string Receive from server Application Object ID for app with specified App Client ID using Client Token (AuthClient::getClientToken()).
getAuthorizationCodeLocation ( ) : string Retrieve location where user must go to receive redirect-callback from Azure with authorization code.
getAvailableServices ( ) : array List of all available services.
getClient ( ) : QueryClient Gets Client
getClientToken ( string $resource = self::URL_GRAPH_WINDOWS ) : object Receive short-time-live client token to use in GraphClient.
getContributorRoleAssignmentInfo ( string $subscriptionId, string $appObjectId, string $contributorRoleId ) : Scalr\Service\Azure\DataType\RoleAssignmentData Get Role Assignment list in specified subscription.
getContributorRoleId ( string $subscriptionId ) : string Get Contributor Role Id for specified subscription.
getEnvironment ( ) : Scalr_Environment Gets an Scalr Environment object which is associated with the Azure client instance
getLocationsList ( string $namespace = GeoLocationData::RESOURCE_PROVIDER_COMPUTE ) : Scalr\Service\Azure\DataType\GeoLocationData List all of the available geo-locations where user can create resource groups and resources.
getProvidersList ( string $subscriptionId ) : Scalr\Service\Azure\DataType\ProviderList List information about all of the available resource providers and whether they are registered with the subscription.
getProxy ( ) : array | boolean Gets proxy configuration
getRefreshToken ( ) : object Getter for Refresh Token.
getRoleAssignmentInfo ( string $subscriptionId, string $roleAssignmentId ) : Scalr\Service\Azure\DataType\RoleAssignmentData Get Role Assignment info in specified subscription.
getSubscriptionsList ( ) : Scalr\Service\Azure\DataType\SubscriptionList Get list of all user subscriptions.
registerSubscription ( string $subscriptionId, string $resourceProvider ) : Scalr\Service\Azure\DataType\ProviderData Register a subscription with a resource provider.
setAccessToken ( string $token, string $expireDate, string $error = null ) Setter for Access Token.
setEnvironment ( Scalr_Environment $environment = null ) : Azure Sets an Scalr environment object which is associated with the Azure client instance
setProxy ( string $host, integer $port = 3128, string $user = null, string $pass = null, integer $type, integer $authType = 1 ) Set proxy configuration to connect to AWS services
unregisterSubscription ( string $subscriptionId, string $resourceProvider ) : Scalr\Service\Azure\DataType\ProviderData Unregister a subscription from a resource provider.
validateTenantName ( ) : boolean Validate tenant name.

Protected Methods

Method Description
getToken ( string $grantType, string $resource, string $refreshToken = null, string $authorizationCode = null ) : object Receive token.

Private Methods

Method Description
loadToken ( string $type ) : object Load token from storage (DB in future).

Method Details

__construct() public method

Constructor.
public __construct ( string $appClientId, string $appSecretKey, string $tenantName )
$appClientId string Application Client ID
$appSecretKey string Application Secret Key
$tenantName string Name of tenant.

__get() public method

Magic getter.
public __get ( string $name ) : Scalr\Service\Azure\AbstractService
$name string
return Scalr\Service\Azure\AbstractService

assignContributorRoleToApp() public method

Assign Contributor Role Id to specified app.
public assignContributorRoleToApp ( string $subscriptionId, string $roleAssignmentId, string $appObjectId, string $contributorRoleId ) : Scalr\Service\Azure\DataType\RoleAssignmentData
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
$roleAssignmentId string New role assignment id
$appObjectId string Application Object Id
$contributorRoleId string Contributor Role Id
return Scalr\Service\Azure\DataType\RoleAssignmentData Server response body (JSON)

deleteRoleAssignment() public method

Delete role assignment.
public deleteRoleAssignment ( string $subscriptionId, string $roleAssignmentId ) : boolean
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
$roleAssignmentId string Role assignment id
return boolean

getAccessToken() public method

Gets Access Token.
public getAccessToken ( ) : object
return object stdClass with next properties : token, expireDate and error. $accesToken is invalid, when error is not null

getAccessTokenByAuthCode() public method

Receive access token from server using Authorisation Code.
public getAccessTokenByAuthCode ( string $authorizationCode ) : object
$authorizationCode string Code, received from server
return object stdClass with next properties : token, expireDate and error. $accesToken is invalid, when error is not null

getAppObjectId() public method

Receive from server Application Object ID for app with specified App Client ID using Client Token (AuthClient::getClientToken()).
public getAppObjectId ( ) : string
return string Application Object ID

getAuthorizationCodeLocation() public method

Retrieve location where user must go to receive redirect-callback from Azure with authorization code.
public getAuthorizationCodeLocation ( ) : string
return string URL for access code request

getAvailableServices() public method

List of all available services.
public getAvailableServices ( ) : array
return array Service names

getClient() public method

Gets Client
public getClient ( ) : QueryClient
return Scalr\Service\Azure\Client\QueryClient Returns QueryClient

getClientToken() public method

Receive short-time-live client token to use in GraphClient.
public getClientToken ( string $resource = self::URL_GRAPH_WINDOWS ) : object
$resource string
return object stdClass with next properties : token, expireDate and error. $clientToken is invalid, when error is not null

getContributorRoleAssignmentInfo() public method

Get Role Assignment list in specified subscription.
public getContributorRoleAssignmentInfo ( string $subscriptionId, string $appObjectId, string $contributorRoleId ) : Scalr\Service\Azure\DataType\RoleAssignmentData
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
$appObjectId string Application Object Id
$contributorRoleId string Contributor Role Id
return Scalr\Service\Azure\DataType\RoleAssignmentData Server response body (JSON)

getContributorRoleId() public method

Get Contributor Role Id for specified subscription.
public getContributorRoleId ( string $subscriptionId ) : string
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
return string Contributor Role Id

getEnvironment() public method

Gets an Scalr Environment object which is associated with the Azure client instance
public getEnvironment ( ) : Scalr_Environment
return Scalr_Environment Returns Scalr Environment object

getLocationsList() public method

List all of the available geo-locations where user can create resource groups and resources.
public getLocationsList ( string $namespace = GeoLocationData::RESOURCE_PROVIDER_COMPUTE ) : Scalr\Service\Azure\DataType\GeoLocationData
$namespace string Resource provider
return Scalr\Service\Azure\DataType\GeoLocationData Object described on https://msdn.microsoft.com/en-us/library/azure/dn790540.aspx

getProvidersList() public method

List information about all of the available resource providers and whether they are registered with the subscription.
public getProvidersList ( string $subscriptionId ) : Scalr\Service\Azure\DataType\ProviderList
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
return Scalr\Service\Azure\DataType\ProviderList

getProxy() public method

Gets proxy configuration
public getProxy ( ) : array | boolean
return array | boolean

getRefreshToken() public method

Getter for Refresh Token.
public getRefreshToken ( ) : object
return object stdClass with next properties : token, expireDate and error.

getRoleAssignmentInfo() public method

Get Role Assignment info in specified subscription.
public getRoleAssignmentInfo ( string $subscriptionId, string $roleAssignmentId ) : Scalr\Service\Azure\DataType\RoleAssignmentData
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
$roleAssignmentId string Role assignment id
return Scalr\Service\Azure\DataType\RoleAssignmentData Server response body (JSON)

getSubscriptionsList() public method

Get list of all user subscriptions.
public getSubscriptionsList ( ) : Scalr\Service\Azure\DataType\SubscriptionList
return Scalr\Service\Azure\DataType\SubscriptionList List of subscription objects

getToken() protected method

Receive token.
protected getToken ( string $grantType, string $resource, string $refreshToken = null, string $authorizationCode = null ) : object
$grantType string Grant type
$resource string Resource
$refreshToken string optional Refresh Token value
$authorizationCode string
return object Object with next properties : token, expireDate and error. Token is invalid, when error is not null

registerSubscription() public method

Register a subscription with a resource provider.
public registerSubscription ( string $subscriptionId, string $resourceProvider ) : Scalr\Service\Azure\DataType\ProviderData
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
$resourceProvider string The namespace of the resource provider with which you want to register your subscription
return Scalr\Service\Azure\DataType\ProviderData

setAccessToken() public method

Setter for Access Token.
public setAccessToken ( string $token, string $expireDate, string $error = null )
$token string Access Token body
$expireDate string Access Token expire date (unixtime)
$error string optional Access Token error description

setEnvironment() public method

Sets an Scalr environment object which is associated with the Azure client instance
public setEnvironment ( Scalr_Environment $environment = null ) : Azure
$environment Scalr_Environment An environment object
return Azure

setProxy() public method

Set proxy configuration to connect to AWS services
public setProxy ( string $host, integer $port = 3128, string $user = null, string $pass = null, integer $type, integer $authType = 1 )
$host string
$port integer
$user string
$pass string
$type integer Allowed values 4 - SOCKS4, 5 - SOCKS5, 0 - HTTP
$authType integer Allowed authtypes: 1 - Basic, Digest - 2, GSSNeg - 4, NTLM - 8, any - -1

unregisterSubscription() public method

Unregister a subscription from a resource provider.
public unregisterSubscription ( string $subscriptionId, string $resourceProvider ) : Scalr\Service\Azure\DataType\ProviderData
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
$resourceProvider string The namespace of the resource provider with which you want to unregister from your subscription
return Scalr\Service\Azure\DataType\ProviderData

validateTenantName() public method

Validate tenant name.
public validateTenantName ( ) : boolean
return boolean Return true, if tenantName is valid, else return false