genvid.toolbox.AzureStorageAccount¶
-
class
genvid.toolbox.
AzureStorageAccount
(bastionAPI, default_region=None)¶ Bases:
object
Utilities to create and manipulate Azure Storage Account.
-
AZURE_STORAGE_ACCOUNT
¶ A mirror of
AZURE_STORAGE_ACCOUNT
, giving the name of the Azure Storage Account
-
AZURE_RESOURCE_GROUP
¶ A mirror of
AZURE_RESOURCE_GROUP
, giving the name of the Azure resource group.
-
AZURE_DEFAULT_REGION
¶ Returns: The default region name.
-
get_storage_account_name
()¶ Retrieves the name of storage account to use.
Note
Name of storage acount must be unique, between 3 to 24 characters, and can only contain numbers and lowercase letters.
Returns: self.AZURE_STORAGE_ACCOUNT if the environment variable is set. Otherwise, a manipulated storage account name is returned.
-
create_storage_account
(storage_account: str, resource_group: str = None)¶ Creates storage account if it doesn’t exists.
The create command will create the account if it does not exist. Othervise, the command will be ignored.
Parameters: - storage_account – The name of storage account to create.
- resource_group – Resource group to be used.
-
list_storage_accounts
(resource_group: str = None) → list¶ List Storage accounts in the resource group.
Parameters: resource_group – Resource group to be used.
-
get_connection_string
(storage_account: str, resource_group: str = None) → str¶ Get the connection string for the storage account.
Parameters: - storage_account – The name of storage account for which connection string needs to be retrieved.
- resource_group – Resource group to be used.
Returns: Connection String for storage account.
-
create_resource_group
(region: str = None, resource_group: str = None)¶ Creates Resource Group if it doesn’t exists.
If the resource group already exists, nothing will be done. Othervise, a resource gorup in specified region will be created.
Parameters: - region – Region in which resource group needs to be created.
- resource_group – Resource group to be created.
-
check_resource_group_exist
(resource_group: str = None)¶ Check if resource group exists.
Parameters: resource_group – Resource group to be checked. Returns: True if the resource group exists, False othervise.
-
get_tenant_id
()¶ Gets the tenant id of the azure account.
Returns: Tenant ID of azure account.
-
upload_blob
(storage_account: str, container_name: str, blob_name: str, filepath: typing.Union[str, pathlib.Path])¶ Upload specific blob to an Azure Container.
Parameters: - storage_account – Name of storage account.
- container_name – The name of container to operate on.
- blob_name – Name of the blob to be uploaded
- filepath – Path to the file to be uploaded.
-
add_allowed_ip
(storage_account: str, ip: str)¶ Add the IP address to allowed list.
Parameters: - storage_account – Name of storage account.
- ip – IP Address to be added.
-
delete_blob
(storage_account: str, container_name: str, blob_name: str)¶ Delete specific blob to an Azure Container.
Parameters: - storage_account – Name of storage account.
- container_name – The name of container to operate on.
- blob_name – Name of the blob to be Deleted
-
create_container
(storage_account: str, container_name: str, access_level: str = 'blob')¶ Create an Azure Container.
Parameters: - storage_account – Name of storage account.
- container_name – The name of container to operate on.
- access_level – Access level of blob.
-
list_containers
(storage_account: str)¶ List the containers in storage account.
Parameters: storage_account – Name of storage account.
-
list_allowed_ips
(storage_account: str) → list¶ List the of allowed IP address for a storage account.
Parameters: storage_account – Name of storage account. Returns: List of allowed IP addresses.
-
list_images
(storage_account: str, container_name: str, prefix: str)¶ List of images for specific path in the Container.
Parameters: - storage_account – Name of storage account.
- container_name – The name of container to operate on.
- prefix – Prefix of image/blob.
Returns: List of Images/blobs.
-
-
class
azure_storage.
AzureStorageAccount
¶ Implementation of
genvid.toolbox.AzureStorageAccount