rubrik_polaris.common package¶
Submodules¶
rubrik_polaris.common.connection module¶
Collection of methods that control connection with Polaris.
-
rubrik_polaris.common.connection.
return_http_error_message
(status_code)¶ Returns HTTP error message, either custom or standard based on the status code input
- Parameters
status_code – Error status code
- Returns
Http error message
rubrik_polaris.common.core module¶
Collection of functions that interact with Polaris primitives.
-
rubrik_polaris.common.core.
get_sla_domains
(self, 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()
-
rubrik_polaris.common.core.
submit_on_demand
(self, 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)
-
rubrik_polaris.common.core.
submit_assign_sla
(self, 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)
-
rubrik_polaris.common.core.
get_polaris_version
(self)¶ Retrieve deployment version from Polaris
- Returns
Polaris deployment version
- Return type
str
- Raises
RequestException – If the query to Polaris returned an error
-
rubrik_polaris.common.core.
get_task_status
(self, 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
-
rubrik_polaris.common.core.
get_snapshots
(self, 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])
-
rubrik_polaris.common.core.
get_event_series_list
(self, 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
-
rubrik_polaris.common.core.
get_report_data
(self, 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
-
rubrik_polaris.common.core.
list_event_series
(self, 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
rubrik_polaris.common.graphql module¶
Collection of methods that interact with the raw GraphQL.
-
rubrik_polaris.common.graphql.
get_enum_values
(self, name=None)¶ Retrieve Enum Values via Introspection
rubrik_polaris.common.monitor module¶
Collection of methods that monitor tasks
rubrik_polaris.common.object module¶
Collection of methods that are related to objects (virtual machines, filesets etc).
-
rubrik_polaris.common.object.
list_vm_objects
(self, 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
-
rubrik_polaris.common.object.
search_object
(self, 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
-
rubrik_polaris.common.object.
get_object_metadata
(self, 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
-
rubrik_polaris.common.object.
get_object_snapshot
(self, 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
-
rubrik_polaris.common.object.
list_objects
(self, 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
-
rubrik_polaris.common.object.
list_object_snapshots
(self, 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
rubrik_polaris.common.user module¶
Collection of methods for user.
-
rubrik_polaris.common.user.
get_user_downloads
(self)¶ To retrieve the user.
- Returns
Dictionary containing download user information.
- Return type
dict
- Raises
RequestException – If the query to Polaris returned an error.
rubrik_polaris.common.validations module¶
-
rubrik_polaris.common.validations.
check_first_arg
(self, 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
-
rubrik_polaris.common.validations.
to_boolean
(self, value)¶ Converts value into a boolean type. :param value: argument for type casting
- Returns
Either True or False
Raises ValueError
-
rubrik_polaris.common.validations.
validate_id
(self, 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
-
rubrik_polaris.common.validations.
check_enum
(self, 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]