rubrik_polaris package¶
Subpackages¶
Submodules¶
rubrik_polaris.appflows module¶
Collection of functions that manipulate appflows components
-
rubrik_polaris.appflows.
get_appflows_blueprints
(self, blueprint_name='')¶ Retrieves dictionary of AppFlows blueprints including identifiers and additional details.
- Keyword Arguments
blueprint_name (str) – {‘’})
- Returns
dict – A single AppFlows blueprint dict if a non-empty blueprint_name is given and found. list – The complete set of AppFlows blueprints in a list of dictionaries.
rubrik_polaris.cluster module¶
Collection of functions that manipulate CDM Cluster components
-
rubrik_polaris.cluster.
get_cdm_cluster_location
(self, cluster_id)¶ Retrieves the location address for a CDM Cluster :param cluster_id: The ID of a CDM cluster :type cluster_id: str
- Returns
The Cluster location address str: Cluster location has not be configured. str: A cluster with an ID of {cluster_id} was not found.
- Return type
str
- Raises
RequestException – If the query to Polaris returned an error
-
rubrik_polaris.cluster.
get_cdm_cluster_connection_status
(self, cluster_id)¶ Retrieves the Polaris connection status for a CDM Cluster :param cluster_id: The ID of a CDM cluster :type cluster_id: str
- Returns
The Cluster connection status.
- Return type
str
- Raises
RequestException – If the query to Polaris returned an error
rubrik_polaris.exceptions module¶
-
exception
rubrik_polaris.exceptions.
PolarisException
¶ Bases:
Exception
Base class for exceptions in this module.
-
exception
rubrik_polaris.exceptions.
RequestException
¶ Bases:
rubrik_polaris.exceptions.PolarisException
Exceptions during requests, e.g. connection, timeout, HTTP errors.
-
exception
rubrik_polaris.exceptions.
ValidationException
¶ Bases:
rubrik_polaris.exceptions.PolarisException
Exceptions during validation of requests.
-
exception
rubrik_polaris.exceptions.
AuthenticationException
¶ Bases:
rubrik_polaris.exceptions.RequestException
Exceptions during authentication failure
-
exception
rubrik_polaris.exceptions.
ProxyException
¶ Bases:
rubrik_polaris.exceptions.RequestException
Exception during proxy call
rubrik_polaris.logger module¶
-
rubrik_polaris.logger.
logging_setup
(logging_handler, logging_level) → logging.Logger¶ - Init logger object for logging in rubrik-sdk
For more info - https://docs.python.org/3/library/logging.html
- Parameters
logging_level (int) – Log level
logging_handler (Handler) – Handler to log
- Returns
logger object
- Return type
logging.Logger
rubrik_polaris.rubrik_polaris module¶
-
class
rubrik_polaris.rubrik_polaris.
PolarisClient
(domain=None, username=None, password=None, json_keyfile=None, logging_handler=<NullHandler (NOTSET)>, logging_level=30, **kwargs)¶ Bases:
object
-
get_sla_domains
(sla_domain_name='')¶ Retrieves dictionary of SLA Domain Names and Identifiers.
- Parameters
sla_domain_name (str) – Rubrik SLA Domain name
- Returns
The complete set of SLA domains or a one element dict if a non-empty sla_domain_name is given and found.
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> client = PolarisClient() >>> sla_domains = client.get_sla_domains()
-
submit_on_demand
(object_ids, sla_id, wait=False)¶ Submits On Demand Snapshot request for the given set of object id’s and assign the given SLA to the snapshots.
- Parameters
object_ids (list) – List of Rubrik Object IDs
sla_id (str) – Rubrik SLA Domain ID
wait (bool) – Threaded wait for all processes to complete
- Returns
List of errors if any occurred
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> object_ids = client.get_object_ids_gce(region='us-west-1') >>> sla_domain_id = client.get_sla_domains('Gold')[0]['id'] >>> client.submit_on_demand(object_ids, sla_domain_id, wait=True)
-
submit_assign_sla
(object_ids=[], sla_id=None, apply_to_existing_snapshots=None, existing_snapshot_retention=None, global_sla_assign_type='protectWithSlaId')¶ Submits a Rubrik SLA change for objects
- Parameters
object_ids (list) – List of Rubrik Object IDs
global_sla_assign_type (str) – Define assignment type noAssignment/doNotProtect/protectWithSlaId
sla_id (str) – Rubrik SLA Domain ID
apply_to_existing_snapshots (bool) – Apply retention policy to pre-existing snapshots
existing_snapshot_retention (str) – Snapshot handling on doNotProtect RETAIN_SNAPSHOTS/KEEP_FOREVER/EXPIRE_IMMEDIATELY
global_sla_assign_type –
…
- Returns
List of objects assigned the SLA
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> object_ids = client.get_object_ids_gce(region='us-west-1') >>> sla_domain_id = client.get_sla_domains('Gold')[0]['id'] >>> client.submit_assign_sla(object_ids, sla_domain_id)
-
get_task_status
(task_chain_id)¶ Retrieve task status from Polaris
- Parameters
task_chain_id (str) – Task Chain UUID from request
- Returns
Task state
- Return type
str
- Raises
RequestException – If the query to Polaris returned an error
-
get_snapshots
(snappable_id=None, recovery_point=None)¶ Retrieve Snapshots for a Snappable from Polaris
- Parameters
snappable_id (str) – Object UUID
recovery_point (str) – Optional datetime of snapshot to return, or ‘latest’, or not defined to return all
- Returns
A dictionary of snapshots or a single snapshot if ‘latest’ was passed as recovery_point. If no snapshots are found, an empty dict is returned.
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> snappables = client.get_object_ids_ec2(tags={"Environment": "staging"}) >>> for snappable in snappables: ... snapshot = client.get_snapshots(snappable, recovery_point='latest') ... if snapshot: ... print(snapshot[0])
-
get_event_series_list
(object_type=[], status=[], activity_type=[], severity=[], cluster_ids=[], start_time=None, end_time=None)¶ Retrieve Events from Polaris
- Parameters
object_type (list) – List of Object Types
status (list) – List of Event Status
activity_type (list) – List of Activity Types
severity (list) – List of severities
cluster_ids (list) – List of Cluster IDs (UUID)
start_date (datetime) – Timestamp to start return set from
end_date (datetime) – Timestamp to end return set from
- Returns
A list of dictionaries of Event Data
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
-
get_report_data
(object_type=[], cluster_ids=[])¶ Retrieve Report Data from Polaris
- Parameters
object_type (list) – List of object type
cluster_ids (list) – List of cluster id’s
- Returns
A list of dictionaries of Report data
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
-
get_polaris_version
()¶ Retrieve deployment version from Polaris
- Returns
Polaris deployment version
- Return type
str
- Raises
RequestException – If the query to Polaris returned an error
-
get_accounts_aws
(filter='')¶ Retrieves AWS account information from Polaris
- Parameters
filter (str) – Search string to filter results
- Returns
Details of AWS accounts in Polaris
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
get_accounts_aws_detail
(filter)¶ Retrieves deployment details for AWS from Polaris
- Parameters
filter (str) – Search string to filter results
- Returns
Details of Azure accounts in Polaris
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
get_account_aws_native_id
(profile='', aws_id=None, aws_secret=None)¶ Retrieves AWS Account ID from local config
- Parameters
profile (str) – Profile name of local configuration
aws_access_key_id (str) – AWS Access key to import to Polaris
aws_secret_access_key (str) – AWS secret of key to import to polaris
- Returns
AWS account name and ID of requested account
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
-
add_account_aws
(aws_regions=[], all=False, aws_profiles=[], aws_access_key_id=None, aws_secret_access_key=None, cloud_account_features=None)¶ Add AWS account to Polaris
- Parameters
aws_regions (list) – List of AWS regions to include in Polaris for imported accounts
aws_profiles (list) – Optional list of local profile names to add to Polaris
all (bool) – Optional set true to import all locally configured profiles to Polaris
aws_access_key_id (str) – AWS Access key of account to import to Polaris
aws_secret_access_key (str) – AWS secret of key of account to import to polaris
cloud_account_features (list) – List of services to enable for cloud account
- Returns
Status if unsuccessful
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> rubrik.add_account_aws(aws_regions = ["us-east-1"], aws_profiles = ["milanese"], cloud_account_features = ["CLOUD_NATIVE_PROTECTION"]) >>> rubrik.add_account_aws(aws_regions = ["us-east-1"], aws_access_key_id='blah', aws_secret_access_key='blah', cloud_account_features = ["CLOUD_NATIVE_PROTECTION"]) >>> rubrik.add_account_aws(aws_regions = ["us-west-2"], all = True , cloud_account_features = ["CLOUD_NATIVE_PROTECTION"])
-
delete_account_aws
(profiles=[], all=False, aws_access_key_id=None, aws_secret_access_key=None)¶ Remove AWS account from Polaris
- Parameters
profiles (list) – Optional list of local profile names to remove from Polaris
all (bool) – Optional set true to remove all locally configured profiles from Polaris
aws_access_key_id (str) – AWS Access key to import to Polaris
aws_secret_access_key (str) – AWS secret of key to import to polaris
- Returns
Status if unsuccessful
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> rubrik.delete_account_aws(profiles = ['milanese_profile']) >>> rubrik.delete_account_aws(aws_access_key_id='blah', aws_secret_access_key='blah') >>> rubrik.delete_account_aws(all = True )
-
get_accounts_azure_native
(filter='')¶ Retrieves Azure native account information from Polaris
- Parameters
filter (str) – Search string to filter results
- Returns
Details of Azure native accounts in Polaris
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
add_account_azure
(azure_tenant_domain_name=None, azure_cloud_type='AZUREPUBLICCLOUD', cloud_account_features='CLOUD_NATIVE_PROTECTION', azure_subscription_id=None, azure_subscription_name=None, azure_regions=None)¶ Add Azure subscription to Polaris :param azure_tenant_domain_name: Optional, Domain Name of the Azure tenant. :type azure_tenant_domain_name: str :param azure_cloud_type: AZUREPUBLICCLOUD [default] or AZURECHINACLOUD :type azure_cloud_type: str :param cloud_account_features: Polaris cloud feature - CLOUDNATIVEPROTECTION [default] :type cloud_account_features: str :param azure_subscription_id: Azure Subscription ID :type azure_subscription_id: str :param azure_subscription_name: Azure Subscription friendly name :type azure_subscription_name: str :param azure_regions: Array of Azure Regions :type azure_regions: arr :param azure_policy_version: Azure Policy version :type azure_policy_version: int
- Returns
Status if unsuccessful
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples:
-
delete_account_azure
(cloud_account_features='CLOUD_NATIVE_PROTECTION', azure_subscription_id=None, delete_snapshots=False)¶ Add Azure subscription to Polaris :param cloud_account_features: Polaris cloud feature - CLOUDNATIVEPROTECTION [default] :type cloud_account_features: str :param azure_subscription_id: Subscription ID from Azure :type azure_subscription_id: string :param delete_snapshots: Delete Rubrik snapshots for subscription [default: False] :type delete_snapshots: bool
- Returns
Status if unsuccessful
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples:
-
set_account_azure_default_sa
(azure_app_id=None, azure_app_secret_key=None, azure_app_tenant_id=None, azure_app_name=None, azure_tenant_domain_name=None, azure_cloud_type='AZUREPUBLICCLOUD', should_replace=False)¶ Set default SA for Azure :param azure_app_id: Client ID of the Application :type azure_app_id: str :param azure_app_secret_key: Client secret key of the Application. :type azure_app_secret_key: str :param azure_app_tenant_id: Optional, ID of the home tenant of the application. :type azure_app_tenant_id: str :param azure_app_name: Optional, Name of the application :type azure_app_name: str :param azure_tenant_domain_name: Optional, Domain Name of the Azure tenant. :type azure_tenant_domain_name: str :param azure_cloud_type: AZUREPUBLICCLOUD [default] or AZURECHINACLOUD :type azure_cloud_type: str
- Returns
Status if unsuccessful
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples:
-
get_accounts_azure_cloud
(cloud_account_features='CLOUD_NATIVE_PROTECTION')¶ Retrieves Azure cloud account information from Polaris
- Parameters
cloud_account_features (str) – Feature string to filter results
- Returns
Details of Azure cloud accounts in Polaris
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
get_accounts_gcp
(filter='')¶ Retrieves GCP project information from Polaris
- Parameters
filter (str) – Search string to filter results
- Returns
Details of GCP Projects in Polaris
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
add_project_gcp
(service_account_auth_key_file=None, gcp_native_project_id=None, gcp_native_project_number=None, gcp_native_project_name=None)¶ Add GCP project to Polaris
- Parameters
service_account_auth_key_file (str) – Filename of SA .json file
gcp_native_project_id (str) – Project_Id of GCP Project to add
gcp_native_project_number (str) – GCP Project number if ommiting SA
gcp_native_project_name (str) – GCP Project name if omitting SA
- Returns
Status if unsuccessful
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> rubrik.add_project_gcp(service_account_auth_key_file="/home/peterm/.google.milanese.json", gcp_native_project_id="home-network-274622")
-
delete_project_gcp
(gcp_native_project_id=None, delete_snapshots=False)¶ Remove GCP project from Polaris
- Parameters
gcp_native_project_id (str) – Project_Id of GCP Project to remove
delete_snapshots (bool) – Should snapshots be removed from Polaris
- Returns
Status if unsuccessful
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> rubrik.delete_project_gcp(gcp_native_project_id="home-network-274622")
-
get_account_gcp_default_sa
()¶ Get default SA Key for GCP
- Returns
Name of default GCP Service Account
- Return type
str
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> rubrik.get_account_gcp_default_sa()
-
set_account_gcp_default_sa
(service_account_auth_key_file=None, service_account_name=None)¶ Set default SA Key for GCP
- Parameters
service_account_auth_key_file (str) – Filename of SA key file
service_account_name (bool) – Name to reference SA
- Returns
Status if unsuccessful
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> rubrik.set_account_gcp_default_sa(service_account_auth_key_file = "file.json", service_account_name = "sa-2021-03")
-
get_compute_object_ids_ec2
(match_all=True, **kwargs)¶ Retrieves all AWS EC2 object IDs that match query
- Parameters
match_all (bool) – Set to false to match ANY defined criteria
tags (dict) – Tags in {Name: Value} format to filter on
kwargs (str) – Any top level object from the get_compute_ec2 call
- Returns
List of all the EC2 object id’s
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
-
get_compute_ec2
(object_id=None)¶ Retrieves all AWS EC2 object details
- Parameters
object_id (str) – optional specific object id to return
- Returns
details of AWS instance objects
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
submit_compute_export_ec2
(snapshot_id=None, aws_account_number=None, aws_region=None, aws_vpc=None, aws_security_groups=None, aws_subnet=None, wait=False, aws_instance_type=None, aws_instance_name=None, copy_tags=True, use_replica=False)¶ Submits an export of a EC2 instance
- Parameters
snapshot_id (str) – snapshot_id to export
aws_account_number (str) – aws account number to recover to
aws_region (str) – aws region to export to
aws_vpc (str) – aws vpc to assign to export
aws_security_groups (list) – aws security groups to assign to export
aws_subnet (str) – aws subnet to assign to export
wait (bool) – Return once complete Defaults to False
- Returns
dict – List of errors if any occurred during the export
-
submit_compute_restore_ec2
(snapshot_id, **kwargs)¶ Submits a Restore of an EC2 instance
- Parameters
snapshot_id (str) – Snapshot ID to be restored
should_power_on (bool) – Defaults to False
should_restore_tags (bool) – Defaults to False
wait (bool) – Return once complete Defaults to False
- Returns
dict – List of errors if any occurred during the restore
-
get_compute_object_ids_azure
(match_all=True, **kwargs)¶ Retrieves all Azure VM object IDs that match query
- Parameters
match_all (bool) – Set to false to match ANY defined criteria
kwargs (str) – Any top level object from the get_compute_ec2 call
- Returns
List of all the VM object id’s
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
-
get_compute_azure
()¶ Retrieves all Azure IAAS object details
- Returns
details of Azure IAAS objects
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
submit_compute_restore_azure
(snapshot_id, **kwargs)¶ Submits a Restore of a Azure VM
- Parameters
snapshot_id (str) – Snapshot ID to be restored
should_power_on (bool) – Defaults to False
should_restore_tags (bool) – Defaults to False
wait (bool) – Return once complete Defaults to False
- Returns
dict – List of errors if any occurred during the restore
-
get_compute_object_ids_gce
(match_all=True, **kwargs)¶ Retrieves all GCP GCE object IDs that match query
- Parameters
match_all (bool) – Set to false to match ANY defined criteria
kwargs (str) – Any top level object from the get_compute_gce call
- Returns
List of all the GCE object id’s
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
-
get_compute_gce
()¶ Retrieves all GCP GCE object details
- Returns
details of GCP GCE objects
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
submit_compute_restore_gce
(snapshot_id, **kwargs)¶ Submits a Restore of a GCE instance
- Parameters
snapshot_id (str) – Snapshot ID to be restored
should_power_on (bool) – Defaults to False
should_restore_tags (bool) – Defaults to False
wait (bool) – Return once complete Defaults to False
- Returns
dict – List of errors if any occurred during the restore
-
get_compute_vsphere
()¶ Retrieves all VMware VM object details (Under development)
- Returns
details of VMware VM objects
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
get_compute_object_ids_vsphere
(match_all=True, **kwargs)¶ Retrieves all vSphere objects that match query
- Parameters
{bool} -- Set to false to match ANY defined criteria (match_all) –
{} -- Any top level object from the get_compute_ec2 call (kwargs) –
-
get_storage_object_ids_ebs
(match_all=True, **kwargs)¶ Retrieves ObjectIds for EBS Snappables from Polaris
- Parameters
match_all (bool) – Set to False to match ANY defined criteria
tags (dict) – Optional allows simple qualification of tags
kwargs (dict) – Optional any top level object from the get_storage_ebs call
- Returns
A list of EBS object IDs matching results of query
- Return type
list
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> snappables = client.get_object_ids_ebs(tags={"Environment": "staging"}) >>> for snappable in snappables: ... snapshot = client.get_snapshots(snappable, recovery_point='latest') ... if snapshot: ... print(snapshot[0])
-
get_storage_ebs
()¶ Retrieves details for all EBS Snappables from Polaris
Args:
- Returns
Dictionary of all EBS Snappable details
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
Examples
>>> snappables = client.get_storage_ebs()
-
get_enum_values
(name=None)¶ Retrieve Enum Values via Introspection
-
get_cdm_cluster_location
(cluster_id)¶ Retrieves the location address for a CDM Cluster :param cluster_id: The ID of a CDM cluster :type cluster_id: str
- Returns
The Cluster location address str: Cluster location has not be configured. str: A cluster with an ID of {cluster_id} was not found.
- Return type
str
- Raises
RequestException – If the query to Polaris returned an error
-
get_cdm_cluster_connection_status
(cluster_id)¶ Retrieves the Polaris connection status for a CDM Cluster :param cluster_id: The ID of a CDM cluster :type cluster_id: str
- Returns
The Cluster connection status.
- Return type
str
- Raises
RequestException – If the query to Polaris returned an error
-
get_appflows_blueprints
(blueprint_name='')¶ Retrieves dictionary of AppFlows blueprints including identifiers and additional details.
- Keyword Arguments
blueprint_name (str) – {‘’})
- Returns
dict – A single AppFlows blueprint dict if a non-empty blueprint_name is given and found. list – The complete set of AppFlows blueprints in a list of dictionaries.
-
check_first_arg
(first)¶ Function to validate a common argument named first
- Parameters
first (Any) – Number of results to retrieve in the response.
- Returns
An integer value if the ‘first’ argument is valid
- Return type
Optional[int]
- Raises
ValueError – If the ‘first’ argument contains invalid value
-
to_boolean
(value)¶ Converts value into a boolean type. :param value: argument for type casting
- Returns
Either True or False
Raises ValueError
-
validate_id
(id_: str, field_name: str)¶ Performs validation for ID :param field_name: The field name for which validation is performed. :param id_: ID to validate.
Returns: return without any error.
Raises: ValueError exception
-
check_enum
(value, field_name, enum_name)¶ Verify the value(s) is/are present in the list of enum values
- Parameters
value – Value(s) to verify
field_name – Name of the field to verify
enum_name – Name of the enum
- Raises
ValueError – If input is invalid
- Returns
Verified value(s)
- Return type
Optional[list, str]
-
list_vm_objects
(filters: Optional[list] = None, first=20, sort_by: Optional[str] = None, sort_order: Optional[str] = None, after: Optional[str] = None)¶ Retrieve a list of all the objects of the VSphere Vm.
- Parameters
first (int) – Limit of results to retrieve. Defaults to 20, if not provided.
sort_by (str) – Field to sort the results.
sort_order (str) – Sort order for the results.
filters (list) – Filter object.
after (str) – the cursor token to retrieve the next set of results.
- Returns
Dictionary of VsphereVm objects
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
search_object
(filters: Optional[list] = None, first: int = 20, sort_by: Optional[str] = None, sort_order: Optional[str] = None, after: Optional[str] = None)¶ Globally searches for objects on Rubrik Polaris platform
- Parameters
filters (list) – A list of filters of type ‘Filter’ which include key fields field, texts, tagFilterParams, objectTypeFiltersParams, awsNativeProtectionFeatureNames, isNegative and isSlowSearchEnabled.
first (int) – Number of objects to retrieve. Defaults to 20, if not provided.
sort_by (str) – the field to use for sorting the objects (Possible values can be obtained by querying the values ‘HierarchySortByField’ of Enum). If not provided, will return the default sorted response.
sort_order (str) – the order to sort objects in (Possible values ‘ASC’ and ‘DESC’). If not provided, will return the default sorted response.
after (str) – the cursor token to retrieve the next set of results.
- Returns
The global search results object
- Return type
Dict
- Raises
RequestException – If the query to Polaris returned an error
ValueError – if arguments are incorrect
-
get_object_metadata
(object_id)¶ Retrieve details for a Vsphere object based on the provided object ID.
- Parameters
object_id (str) – The ID of the object to get details.
- Returns
Response from the API.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
get_object_snapshot
(object_id, snapshot_group_by, missed_snapshot_group_by, time_range, timezone_offset, cluster_connected)¶ Search for a Rubrik snapshot of an object based on the provided snapshot ID, exact timestamp, or specific value like earliest/latest, or closest before/after a timestamp.
- Parameters
object_id (str) – The object ID for which the snapshots are to be searched.
snapshot_group_by (str) – Grouping the snapshots on the basis of the selected value. Possible values are: “Month”, “Day”, “Year”, “Week”, “Hour”, “Quarter”.
missed_snapshot_group_by (str) – Grouping the missed snapshots on the basis of the selected value. Possible values are: “Month”, “Day”, “Year”, “Week”, “Hour”, “Quarter”.
time_range (dict) – The time range to get snapshots from and until.
timezone_offset (float) – The timezone offset from UTC changes to match the configured time zone. Use this argument to filter the data according to the provided timezone offset. Formats accepted: 1, 1.5, 2, 2.5, 5.5, etc
cluster_connected (bool) – Whether the cluster is connected or not. Possible values are: True, False.
- Returns
Response from the API.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
list_policy_analyzer_groups
()¶ Retrieve the list of sonar policy analyzer groups.
- Returns
Dictionary of sonar policy analyzer groups.
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error.
-
list_policies
()¶ Retrieves available sonar policies
- Returns
Details of policies
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
trigger_on_demand_scan
(scan_name, resources, analyzer_groups)¶ Trigger an on-demand scan of a system (specifying policies to search for).
- Parameters
scan_name (str) – Name of the scan.
analyzer_groups (list) – List of sonar policy analyzer groups.
resources (list) – List of object IDs to scan.
- Returns
Response from the API.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
get_on_demand_scan_status
(crawl_id)¶ Retrieve the list of scan status details.
- Parameters
crawl_id (str) – ID for which scan status is to be obtained.
- Returns
Dictionary of list of scan status details.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
get_on_demand_scan_result
(crawl_id, filters)¶ Retrieve the download link for the requested scanned file.
- Parameters
crawl_id (str) – ID for which file needs to be downloaded.
filters (dict) – Dictionary of filter containing file type.
- Returns
Dictionary containing download link for the result file.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
get_sensitive_hits_object_list
(day: str, timezone: str)¶ To get the sonar sensitive hits object list.
- Parameters
day (str) – Specify the date.
timezone (str) – Specify timezone.
- Returns
Dictionary containing list of sonar sensitive hits object.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
get_sensitive_hits_object_detail
(snapshot_id: str, snappable_id: str)¶ To get the sonar sensitive hits object details.
- Parameters
snapshot_id (str) – Snapshot ID to get results.
snappable_id (str) – Snappable(Object) ID to get results.
- Returns
Dictionary containing details of sonar sensitive hits object.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
get_sensitive_hits
(search_time_period: int = 7, object_name=None)¶ To get the sonar sensitive hits.
- Parameters
search_time_period (int) – The number of days in the past to look for sensitive hits.
object_name (str) – The object_name to filter objects.
- Returns
Dictionary containing list of sonar sensitive hits.
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error.
-
get_csv_result
(cluster_id, snapshot_id, snappable_id)¶ Retrieve the download link for the Radar CSV analyzed file .
- Parameters
cluster_id (str) – Cluster ID for analysis.
snapshot_id (str) – Snapshot ID for analysis.
snappable_id (str) – Snappable(Object) ID for analysis.
- Returns
Dictionary containing download link
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
get_csv_download
(snapshot_id, snappable_id, filters=None)¶ Request to download the Sonar CSV Snapshot results file.
- Parameters
snapshot_id (str) – Snapshot ID to get results.
snappable_id (str) – Snappable (Object) ID to get results.
filters (dict) – Filters to download csv file.
- Returns
Dictionary containing status of sonar csv snapshot results file download .
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
get_csv_result_download
(download_id: int)¶ To retrieve the Sonar CSV results file download link.
- Parameters
download_id (int) – ID of CSV results file to be download.
- Returns
Dictionary containing download link of Sonar CSV results file.
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error.
-
get_snapshot_files
(snapshot_id: str, first: Optional[int] = None, path: Optional[str] = None, after: Optional[str] = None, search_prefix: Optional[str] = None)¶ Retrieve the list of the available files that can be downloaded.
- Parameters
first (int) – Number of results to retrieve in the response.
after (str) – The next page cursor to retrieve the next set of results.
path (str) – The path of the folder to list the sub-files. If not provided the root directory files will be returned.
search_prefix (str) – Provide a keyword to search in the file names.
snapshot_id (str) – The Snapshot ID of the file that needs to be downloaded.
- Returns
Dictionary containing list of files
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
request_download_snapshot_files
(snapshot_id: str, paths: list, delta_type_filter: Optional[enumerate] = None, next_snapshot_fid: Optional[str] = None)¶ - Parameters
snapshot_id (str) – The Snapshot ID of the file that needs to be downloaded.
paths (array) – List of paths to download.
delta_type_filter (enumerate) – DeltaTypeEnum filter
next_snapshot_fid (str) – The next Snapshot FID.
- Returns
Dictionary containing list of files
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
create_vm_snapshot
(snapshot_id: str, sla_id: Optional[str] = None)¶ Create snapshot of a system. :param snapshot_id: The Snapshot ID of the snapshot that needs to be created. :param sla_id: The SLA ID of the snapshot that needs to be created.
- Returns:
dict: Dictionary containing snapshot information.
- Raises
RequestException – If the query to Polaris returned an error
-
create_vm_livemount
(snapshot_fid: str, host_id: Optional[str] = None, vm_name: Optional[str] = None, disable_network: Optional[bool] = None, remove_network_devices: Optional[bool] = None, power_on: Optional[bool] = None, keep_mac_addresses: Optional[bool] = None, data_store_name: Optional[str] = None, create_data_store_only: Optional[bool] = None, vlan: Optional[int] = None, should_recover_tags: Optional[bool] = None)¶ Perform a live mount of a virtual machine snapshot. :param snapshot_fid: The Snapshot FID of the snapshot. :param host_id: The Host ID. :param vm_name: The VM Name. :param disable_network: Whether to disable network. :param remove_network_devices: Whether to remove network devices. :param power_on: Whether to power on. :param keep_mac_addresses: Whether to keep MAC address. :param data_store_name: Name of the data store. :param create_data_store_only: Whether to create data store. :param vlan: VLAN ID. :param should_recover_tags: Whether to recover tags.
- Returns
Dictionary containing live mount information
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
create_vm_livemount_v2
(snappable_id: str, should_recover_tags: bool, power_on: bool, keep_mac_addresses: bool, remove_network_devices: bool, host_id: Optional[str] = None, cluster_id: Optional[str] = None, resource_pool_id: Optional[str] = None, snapshot_fid: Optional[str] = None, vm_name: Optional[str] = None, vnic_bindings: Optional[dict] = None, recovery_point: Optional[str] = None)¶ - Perform a live mount of a virtual machine snapshot.
When the snapshot ID is passed without a timestamp, this endpoint triggers a live mount using the given snapshot ID. When this endpoint is passed a recovery point or a recovery point and snapshot ID, the endpoint triggers a live mount using the point in time (PIT) for recovery. Calling this endpoint without a recovery point or a snapshot ID triggers a PIT live mount that uses the most recent time or snapshot available.
- Parameters
snappable_id – The snappable ID.
should_recover_tags – Whether to recover tags.
power_on – Whether to power on.
keep_mac_addresses – Whether to keep MAC addresses.
remove_network_devices – Whether to remove network interfaces from the VM.
host_id – ID of the ESXi host to mount the new VM on.
cluster_id – ID of the compute cluster where the new VM will be mounted.
resource_pool_id – ID of the resource pool where the new VM will be mounted.
snapshot_fid – ID of the snapshot to recover.
vm_name – Name of the new VM.
vnic_bindings –
List of network bindings for vNIC of the VM. e.g.: [
- {
- “backingNetworkInfo”: {
“moid”: <string>, “name”: <string>
}, “networkDeviceInfo”: {
”key”: <int>, “name”: <string>
}
}
]
recovery_point – Point in time to recover to, e.g.: “2023-03-04T05:06:07.890”
-
list_vsphere_hosts
(first: int, after: Optional[str] = None, filters: Optional[list] = None, sort_by: Optional[enumerate] = None, sort_order: Optional[enumerate] = None)¶ Retrieves a list of available Vsphere hosts. :param after: The next page cursor to retrieve the next set of results. :param first: Number of results to retrieve in the response. :param filters: Filters the SLA result. Supported fields of class GlobalSlaQueryFilterInputField. :param sort_by: Sorts the result using HierarchySortByField. :param sort_order: Sorting orders ASC or DESC.
- Returns
Dictionary containing list of Vsphere hosts.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
export_vm_snapshot
(config: dict, id_: str)¶ Export a snapshot of a virtual machine. :param id_: The object ID. :param config: Configuration parameters for exporting snapshot.
- Returns
Dictionary containing snapshot information.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
list_vsphere_datastores
(host_id: str, first: Optional[int] = None, after: Optional[str] = None, filters: Optional[list] = None, sort_by: Optional[enumerate] = None, sort_order: Optional[enumerate] = None)¶ Retrieves a list of datastores on a Vsphere host. :param host_id: The Host ID. :param after: The next page cursor to retrieve the next set of results. :param first: Number of results to retrieve in the response. :param filters: Filters the SLA result. Supported fields of class GlobalSlaQueryFilterInputField. :param sort_by: Sorts the result using HierarchySortByField. :param sort_order: Sorting orders ASC or DESC.
- Returns
Dictionary containing list of Vsphere datastores.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
get_async_request_result
(request_id: str, cluster_id: str)¶ Retrieves the result of an asynchronous request. These requests can be triggered by calling functions such as export_vm_snapshot, create_vm_livemount, request_download_snapshot_files or create_vm_snapshot. :param request_id: The ID of the asynchronous request. :param cluster_id: The ID of the cluster where the request was made.
- Returns
Dictionary containing the result of the request.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
recover_vsphere_vm_files
(snapshot_id: str, cluster_id: str, restore_config: Union[dict, list], destination_object_id: Optional[str] = None, should_use_agent: bool = False, should_restore_x_attrs: bool = False, ignore_errors: bool = False)¶ Recover files from a snapshot back into a Vsphere VM. :param snapshot_id: ID of the snapshot from which to recover files. :param cluster_id: ID of the cluster where the snapshot resides. :param restore_config: List or dict of type RestorePathPairInput. :param destination_object_id: ID of the object where the files will be restored into. If not provided, Rubrik will use
the snapshots object.
- Parameters
should_use_agent – Whether to use an agent.
should_restore_x_attrs – Whether to preserve custom attributes of the machine.
ignore_errors – Whether to ignore errors.
- Returns
Dictionary containing recovery request ID.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
list_sla_domains
(after: Optional[str] = None, first: Optional[int] = None, filters: Optional[list] = None, sort_by: Optional[enumerate] = None, sort_order: Optional[enumerate] = None, show_protected_object_count: Optional[bool] = None)¶ - Parameters
after – The next page cursor to retrieve the next set of results.
first – Number of results to retrieve in the response.
filters – Filters the SLA result. Supported fields of class GlobalSlaQueryFilterInputField.
sort_by – Sorts the result using SLAQuerySortByFieldEnum.
sort_order – Sorting orders ASC or DESC.
show_protected_object_count – A Boolean option to return data with protected object count.
- Returns
List of SLAs.
- Return type
iterator
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
list_clusters
(first: Optional[int] = None, after: Optional[str] = None, filters: Optional[dict] = None, sort_by: Optional[enumerate] = None, sort_order: Optional[enumerate] = None)¶ Retrieves a list of available clusters. :param after: The next page cursor to retrieve the next set of results. :param first: Number of results to retrieve in the response. :param filters: Filters the cluster result. Supported fields of class ClusterFilterInput. :param sort_by: Sorts the result using ClusterSortByEnum. :param sort_order: Sorting orders ASC or DESC.
- Returns
List of clusters.
- Return type
iterator
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error.
-
get_analysis_status
(activity_series_id, cluster_id)¶ Retrieve the analysis status result.
- Parameters
activity_series_id – The ID of the Polaris Event Series.
cluster_id – Cluster UUID for analysis.
- Returns
Dictionary containing download link
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
trigger_ioc_scan
(object_ids: Union[str, List[str]], cluster_id: str, indicators_of_compromise: Union[dict, list], scan_name: Optional[str] = None, max_matches_per_snapshot: Optional[int] = None, snapshot_scan_limit: Optional[dict] = None, maximum_file_size_to_scan: Optional[int] = None, minimum_file_size_to_scan: Optional[int] = None, path_to_include: Optional[Union[str, List[str]]] = None, path_to_exclude: Optional[Union[str, List[str]]] = None, path_to_exempt: Optional[Union[str, List[str]]] = None, requested_hash_types: Optional[Union[str, List[str]]] = None)¶ Triggers an Radar IOC scan on multiple systems for specified IOC’s in a cluster.
- Parameters
object_ids (str|list) – ID/ID’s of objects to scan.
cluster_id (str) – Cluster ID on which to run the IOC scan.
indicators_of_compromise (dict|list) – Indicators to scan for. Provide a single object or list of objects of type IndicatorOfCompromiseInput.
scan_name (str) – Name of the scan to trigger.
max_matches_per_snapshot (int) – Maximum number of matches per snapshot, per IOC. Scanning for an IOC within a snapshot will terminate once this many matches have been detected.
snapshot_scan_limit (dict) – Limit which snapshots to include in the malware scan. Provide input object of type MalwareScanSnapshotLimitInput
maximum_file_size_to_scan (int) – Maximum size of file in bytes that will be included in scan.
minimum_file_size_to_scan (int) – Minimum size of file in bytes that will be included in scan.
path_to_include (str|list) – Paths that will be included in the scan.
path_to_exclude (str|list) – Paths that will be excluded from the scan.
path_to_exempt (str|list) – Paths that will be exempted from exclusion in the scan.
requested_hash_types (str|list) – HashType type enum value.
- Returns
Dictionary containing the scan results
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
get_ioc_scan_list
(cluster_id)¶ Get the list of Radar IOC scans on a cluster.
- Parameters
cluster_id (str) – Cluster ID whose IOC scans are to be listed.
- Returns
Dictionary containing the list of IOC scans
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
get_ioc_scan_result
(scan_id: str, cluster_id: str)¶ Retrieve the results of a Radar IOC scan.
- Parameters
scan_id (str) – IOC scan ID.
cluster_id (str) – Cluster ID on which IOC scan was ran.
- Returns
Dictionary containing the scan results
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
list_event_series
(activity_status=None, activity_type=None, object_name=None, object_type=None, start_date=None, end_date=None, severity=None, cluster_id=None, sort_by=None, sort_order=None, after=None, first: int = 20, filters=None)¶ Retrieve the series event list from Rubrik.
- Parameters
first (int) – Number of objects to retrieve. Defaults to 20, if not provided.
activity_status (str) – Activity status of events to retrieve.
activity_type (str) – Activity type of events to retrieve.
object_name (str) – Object name of events to retrieve.
object_type (str) – Object Type of events to retrieve.
start_date (str) – Start date of events to retrieve.
end_date (str) – End date of events to retrieve.
severity (str) – Severity of events to retrieve.
cluster_id (str) – Cluster id of events to retrieve.
sort_by (str) – Sorting the events to retrieve by specific field.
sort_order (str) – Sorting the events to retrieve in specific order.
after (str) – The cursor token to retrieve the next set of results.
filters (dict) – Additional filters, if any, to filter events to retrieve.
- Returns
Response from the API
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
list_objects
(first=20, type_filter=None, sort_by=None, sort_order=None, after=None, filters=None)¶ Retrieve list of objects
- Parameters
first (int) – Number of objects to retrieve. Defaults to 20, if not provided.
type_filter (str) – Type of objects to retrieve. Multiple values can be separated by comma.
sort_by (str) – Field to sort the results.
sort_order (str) – Sort order for the results.
after (str) – The cursor token to retrieve the next set of results.
filters (dict) – Additional filters
- Returns
Response from the API.
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error
-
list_object_snapshots
(object_id, first=20, snapshot_filter=None, sort_by=None, sort_order=None, after=None, start_date=None, end_date=None)¶ Retrieve list of snapshots based on object/snappable Id.
- Parameters
object_id (str) – Snappable/Object ID to get list of snapshots.
first (int) – Number of objects to retrieve. Defaults to 20, if not provided.
snapshot_filter (str) – Raw filter, to filter the results.
sort_by (str) – Field to sort the results.
sort_order (str) – Sort order for the results.
after (str) – The cursor token to retrieve the next set of results.
start_date (str) – The start date to retrieve results from.
end_date (str) – The end date to retrieve results until.
- Returns
Response from the API.
- Return type
dict
- Raises
ValueError – If input is invalid
RequestException – If the query to Polaris returned an error
-
create_k8s_cluster
(cdm_cluster_id, host_list, k8s_cluster_name, kupr_ingress_port, user_port_ranges, rbs_port_ranges, kupr_cluster_type, proxy_url=None)¶ Add a Kubernetes cluster
- Parameters
cdm_cluster_id (uuid) – The ID of the CDM cluster for ON_PREM k8s clusters.
host_list (list) – List of host IPs/hostnames of the k8s nodes.
k8s_cluster_name (str) – Name of the k8s cluster.
kupr_ingress_port (int) – Port on the k8s node for the kupr Ingress Controller.
user_port_ranges (dict) – Node port ranges dedicated for export operations.
rbs_port_ranges (dict) – Ports in the range of node port service range of the Kubernetes cluster.
kupr_cluster_type (str) – KuprClusterType of the k8s cluster.
proxy_url (str) – Proxy URL for egress calls into Polaris
- Returns
Details of created k8s cluster in Polaris
- Return type
dict
- Raises
PolarisException – If the query to Polaris returned an error
Examples
>>> rubrik.create_k8s_cluster( "b946faa1-ee98-4924-affb-9b4315686879", ["1.2.3.4", "1.2.3.5"], 30000, {"portMin": 30100, "portMax": 30200}, {"portMin": 30300, "portMax": 30400}, "ON_PREM" )
-
refresh_k8s_cluster
(kupr_cluster_id, wait=False)¶ Refresh resources of a Kubernetes cluster.
- Parameters
kupr_cluster_id (uuid) – The ID of the kupr cluster to be refreshed.
wait (bool) – Wait for taskchain completion before return
- Returns
Details of the refresh job
- Return type
dict
- Raises
PolarisException – If the query to Polaris returned an error
-
list_k8s_clusters
()¶ List Kubernetes clusters.
Args:
- Returns
List of kubernetes clusters
- Return type
list
- Raises
PolarisException – If the query to Polaris returned an error
-
get_k8s_status
(kupr_cluster_id)¶ Get k8s cluster status
- Parameters
kupr_cluster_id (uuid) – The ID of the kupr cluster to be refreshed.
- Returns
Kubernetes cluster status
- Return type
dict
- Raises
PolarisException – If the query to Polaris returned an error
-
get_k8s_namespaces
(query_filter=None)¶ Get all k8s namespaces
Args:
- Returns
Kubernetes namespaces
- Return type
list
- Raises
PolarisException – If the query to Polaris returned an error
-
get_k8s_namespace
(polaris_id)¶ Get k8s namespace
- Parameters
polaris_id (uuid) – The Polaris UUID for the object.
- Returns
Kubernetes namespace details
- Return type
dict
- Raises
PolarisException – If the query to Polaris returned an error
-
get_user_downloads
()¶ To retrieve the user.
- Returns
Dictionary containing download user information.
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error.
-
authenticate
()¶
-
prepare_headers
()¶
-
Module contents¶
Instantiates Polaris connection context :param domain: Polaris domain identifier. :type domain: str :param username: Polaris username :type username: str :param password: Polaris password :type password: str :param root_domain: Polaris root domain only if not *.my.rubrik.com :type root_domain: str :param insecure: Allow unverified SSL keys :type insecure: bool :param json_keyfile: Service account credential file (used exclusive of first 4 options. :type json_keyfile: str
- returns
Polaris connection context
- rtype
object
- raises RequestException
If the query to Polaris returned an error