cloud_scanner_azure.services package¶
Submodules¶
cloud_scanner_azure.services.azure_cosmosdb module¶
-
class
cloud_scanner_azure.services.azure_cosmosdb.
AzureCosmosDb
(config: cloud_scanner_azure.config.azure_cosmosdb_config.AzureCosmosDbConfig)¶ Bases:
cloud_scanner.contracts.table_storage.TableStorage
Azure CosmosDB provider for Table Storage.
-
check_entry_exists
(entry)¶ Check if entry exists in table.
Parameters: entry – Dictionary with PartitionKey and RowKey fields Returns: True if entry exists
-
static
create
()¶ Initialize AzureCosmosDb service.
Returns: AzureCosmosDb service object
-
delete
(partition_key, row_key)¶ Delete entry with specified partition and row keys.
Parameters: - partition_key – Partition key for entry
- row_key – Row key for entry
Returns: None
-
query
(partition_key, row_key)¶ Get entry with specified partition and row keys.
Parameters: - partition_key – Partition key for entry
- row_key – Row key for entry
Returns: Entity if found, None otherwise
-
query_list
()¶ Get entities from table.
Returns: List of entities from table
-
write
(resource)¶ Write resource to table.
Parameters: resource – Expecting Resource object (see Common.Contracts.Resource) Returns: None
-
cloud_scanner_azure.services.azure_resource module¶
cloud_scanner_azure.services.azure_resource_service module¶
-
class
cloud_scanner_azure.services.azure_resource_service.
AzureResourceService
(config: cloud_scanner_azure.config.azure_resource_config.AzureResourceServiceConfig)¶ Bases:
cloud_scanner.contracts.resource_service.ResourceService
Service for querying Azure resources.
-
static
create
(subscription_id)¶ Instantiate AzureResourceService for specified subscription.
Parameters: subscription_id – Subscription to manage with service Returns: AzureResourceService object
-
get_filter
(payload)¶ Returns filter object based on payload.
Parameters: payload – Filter type. If payload is one of the known resource types, returns AzureResourceTypeFilter with long type name. Users can also directly specify long type name (e.g. Microsoft.Compute/virtualMachines) and it will be used as the resource filter. No other filter types are supported except NoFilter. Returns: Filter object
-
get_resources
(filter: cloud_scanner.contracts.resource_service.ResourceFilter = None)¶ Get resources based on filter.
Parameters: filter – Filter for resources Returns: List of AzureResource objects as serialized from client
-
name
¶ Name of cloud provider.
Returns: ‘azure’
-
update_resource
(resource: cloud_scanner_azure.services.azure_resource.AzureResource)¶ Updates Azure resource.
Parameters: resource – AzureResource object to update Returns:
-
static
cloud_scanner_azure.services.azure_storage_container module¶
-
class
cloud_scanner_azure.services.azure_storage_container.
AzureStorageContainer
(container_name, config: cloud_scanner_azure.config.azure_storage_config.AzureStorageConfig)¶ Bases:
cloud_scanner.contracts.storage_container.StorageContainer
Azure implementation of Storage Container using BlockBlobService.
-
static
create
()¶ Initialize AzureStorageContainer with name and creds from config.
Returns:
-
get_blob_to_text
(file_name)¶ Get string from contents of blob.
Parameters: file_name – Name of blob file Returns: Text from blob file
-
list_blobs
()¶ List all blobs in container.
Returns: List of blobs in container
-
upload_text
(blob_name, text)¶ Uploads text to a new blob.
Parameters: - blob_name – Name to give new blob
- text – Text to upload
Returns: None
-
static
cloud_scanner_azure.services.azure_storage_queue module¶
-
class
cloud_scanner_azure.services.azure_storage_queue.
AzureStorageQueue
(queue_name, config: cloud_scanner_azure.config.azure_storage_config.AzureStorageConfig)¶ Bases:
cloud_scanner.contracts.queue.Queue
Interface for interacting with an Azure Storage Queue (through the Queue contract)
-
static
create
(queue_name: str)¶ Helper function for creating a Azure Storage Queue from the storage_config property defined inside of AzureConfig.
-
peek
()¶ Peeks the fist message from the queue and returns it.
-
pop
()¶ Pops the first message from the queue and returns it.
-
push
(message)¶ Pushes a new message onto the queue.
-
static
cloud_scanner_azure.services.azure_subscription_service module¶
-
class
cloud_scanner_azure.services.azure_subscription_service.
AzureSubscriptionService
(config: cloud_scanner_azure.config.azure_credential_config.AzureCredentialConfig)¶ Bases:
cloud_scanner.contracts.account_service.AccountService
Service to get available subscriptions from Azure.
-
static
create
()¶ Returns: Initialized AzureSubscriptionService object with creds from config
-
get_accounts
()¶ Returns: List of subscription dictionaries with ‘subscriptionId’ and ‘displayName’ fields
-
static