Cloudwanderer Boto3 Interface¶
Code which abstracts away the majority of boto3 interrogation.
Provides simpler methods for CloudWanderer
to call.
-
class
CloudWandererBoto3Interface
(boto3_session=None)¶ Simplifies lookup of boto3 services and resources.
-
get_all_resource_services
(client_args=None)¶ Return all the boto3 service Resource objects that are available, both built-in and custom.
- Parameters
client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
Iterator[boto3.resources.base.ServiceResource]
-
get_boto3_resource_service
(service_name, client_args=None)¶ Return the boto3 service Resource object matching this service_name.
- Parameters
service_name (str) – The name of the service (e.g.
'ec2'
) to get.client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
-
get_custom_resource_service
(service_name, client_args)¶ Get the custom resource definition matching this service name.
- Parameters
service_name (str) – The name of the service (e.g.
'ec2'
) to get.client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
-
get_resource_collection_by_resource_type
(boto3_service, resource_type)¶ Return the resource collection that matches the resource_type (e.g. instance).
This is as opposed to the collection name (e.g. instances)
- Parameters
boto3_service (boto3.resources.base.ServiceResource) –
resource_type (str) –
- Return type
Iterator[boto3.resources.model.Collection]
-
get_resource_collections
(boto3_service)¶ Return all resource types in this service.
- Parameters
boto3_service (boto3.resources.base.ServiceResource) –
- Return type
-
get_resource_from_collection
(boto3_service, boto3_resource_collection)¶ Return all resources of this resource type (collection) from this service.
- Parameters
boto3_service (boto3.resources.base.ServiceResource) –
boto3_resource_collection (boto3.resources.model.Collection) –
- Return type
Iterator[boto3.resources.model.ResourceModel]
-
get_resource_service_by_name
(service_name, client_args=None)¶ Return all services matching name, boto3 or custom.
- Parameters
service_name (str) – The name of the service (e.g.
'ec2'
) to get.client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
Iterator[boto3.resources.base.ServiceResource]
-
get_resources_of_type
(service_name, resource_type, client_args)¶ Return all resources of resource_type.
- Parameters
service_name (str) – The name of the service to get resource for (e.g.
'ec2'
)resource_type (str) – The type of resource to get resources of (e.g.
'instance'
client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
Iterator[boto3.resources.model.ResourceModel]
-
get_service_resource_collection_names
(service_name)¶ Return all possible resource collection names for a given service.
Returns collection names for both native boto3 resources and custom cloudwanderer resources.
- Parameters
service_name (str) – The name of the service to get resource types for (e.g.
'ec2'
)- Return type
Iterator[str]
-
get_service_resource_collections
(service_name)¶ Return all the resource collections for a given service_name.
This is crucial to return collections for both native boto3 resources and custom cloudwanderer resources.
- Parameters
service_name (str) – The name of the service to get resource types for (e.g.
'ec2'
)- Return type
Iterator[boto3.resources.model.Collection]
-
get_service_resource_types
(service_name)¶ Return all possible resource names for a given service.
Returns resources for both native boto3 resources and custom cloudwanderer resources.
- Parameters
service_name (str) – The name of the service to get resource types for (e.g.
'ec2'
)- Return type
Iterator[str]
-
-
class
CustomAttributesInterface
(boto3_session)¶ Simplifies lookup of CloudWanderer custom attributes.
Custom attributes use the
boto3.resources.base.ServiceResource
model to load attribute information. This means we can use a lot of the methods fromCloudWandererBoto3Interface
in this class by inherting them. We simply have to override a few in order to load the attribute definitions.- Parameters
boto3_session (boto3.session.Session) – The
boto3.session.Session
object to use for any queries.
-
get_resource_attributes_service_by_name
(service_name, client_args=None)¶ Return the boto3.resource service containing a collection of resource attributes provided by CloudWanderer.
These custom resource attribute definitions allow us to fetch resource attributes that are not returned by the resource’s default describe calls.
- Parameters
service_name (str) – The name of the service (e.g.
'ec2'
) to get.client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
Iterator[boto3.resources.model.ResourceModel]
-
get_resource_from_collection
(boto3_service, boto3_resource_collection)¶ Return a boto3.resource pertaining to a resource attribute defined by CloudWanderer.
These custom resource attribute definitions allow us to fetch resource attributes that are not returned by the resource’s default describe calls.
- Parameters
boto3_service (boto3.resources.base.ServiceResource) – The boto3.resource service from self.get_resource_attributes_service_by_name
boto3_resource_collection (boto3.resources.model.Collection) – The boto3 collection of attributes we want to retrieve.
- Return type
Iterator[boto3.resources.model.ResourceModel]
-
get_resource_service_by_name
(service_name, client_args=None)¶ Overrides method from CloudWandererBoto3Interface so we can reuse its methods which depend upon this one.
- Parameters
service_name (str) – The name of the service (e.g.
'ec2'
) to get.client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
Iterator[boto3.resources.base.ServiceResource]