Workload Package
CIS Benchmarks
Model and Query Classes for Compliance Assessment API
- class ComplianceBenchmark(cb, model_unique_id, initial_data=None)
Bases:
UnrefreshableModel
Class representing Compliance Benchmarks.
- Parameters:
id – Unique identifier for the benchmark set.
name – Name of the benchmark set.
version – Version of the benchmark set.
os_family – Operating system family associated with the benchmark set (e.g., WINDOWS_SERVER).
enabled – Indicates whether the benchmark set is enabled or not.
type – Type of the benchmark set (e.g., Custom).
supported_os_info – Array of supported operating system information.
created_by – Name of the user who created the benchmark set.
updated_by – Email of the user who last updated the benchmark set.
create_time – Timestamp indicating when the benchmark set was created (in ISO 8601 format).
update_time – Timestamp indicating when the benchmark set was last updated (in ISO 8601 format).
release_time – Timestamp indicating when the benchmark set was released (in ISO 8601 format).
Initialize a ComplianceBenchmark instance.
- Parameters:
cb (CBCloudAPI) – Instance of CBCloudAPI.
initial_data (dict) – Initial data for the instance.
model_unique_id (str) – Unique identifier for the model.
- Returns:
An instance of ComplianceBenchmark.
- Return type:
- execute_action(action, device_ids=None)
Execute a specified action for the Benchmark Set for all devices or a specified subset.
- Required Permissions:
complianceAssessment.data(EXECUTE)
- Parameters:
action (str) – The action to be executed. Options: ENABLE, DISABLE, REASSESS
device_ids (str or list, optional) – IDs of devices on which the action will be executed. If specified as a string, only one device will be targeted. If specified as a list, the action will be executed on multiple devices. Default is None.
- Returns:
JSON response containing information about the executed action.
- Return type:
dict
- Raises:
ApiError – If the provided action is not one of the allowed actions.
Example
To reassess an object: benchmark_sets = cb.select(ComplianceBenchmark) benchmark_sets[0].execute_action(‘REASSESS’)
- get(attrname, default_val=None)
Return an attribute of this object.
- Parameters:
attrname (str) – Name of the attribute to be returned.
default_val (Any) – Default value to be used if the attribute is not set.
- Returns:
The returned attribute value, which may be defaulted.
- Return type:
Any
- static get_compliance_schedule(cb)
Gets the compliance scan schedule and timezone configured for the Organization.
- Parameters:
cb (CBCloudAPI) – An instance of CBCloudAPI representing the Carbon Black Cloud API.
- Required Permissions:
complianceAssessment.data(READ)
- Raises:
ApiError – If cb is not an instance of CBCloudAPI.
- Returns:
The configured organization settings for Compliance Assessment.
- Return type:
dict
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> schedule = ComplianceBenchmark.get_compliance_schedule(cb) >>> print(schedule)
- get_device_compliances(query='')
Fetches devices compliance summaries associated with the benchmark set.
- Required Permissions:
complianceAssessment.data(READ)
- Parameters:
query (str, optional) – The query to filter results.
- Returns:
List of Device Compliances
- Return type:
[dict]
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> benchmark_set = cb.select(ComplianceBenchmark).first() >>> device_compliances = benchmark_set.get_device_compliance()
- get_device_rule_compliances(device_id, query='')
Fetches rule compliances for specific device.
- Required Permissions:
complianceAssessment.data(READ)
- Parameters:
device_id (int) – Device id to fetch benchmark rule compliance
query (str, optional) – The query to filter results.
- Returns:
List of Rule Compliances
- Return type:
[dict]
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> benchmark_set = cb.select(ComplianceBenchmark).first() >>> rules = benchmark_set.get_device_rule_compliance(123)
- get_rule_compliance_devices(rule_id, query='')
Fetches device compliances for a specific rule.
- Required Permissions:
complianceAssessment.data(READ)
- Parameters:
rule_id (str) – Rule id to fetch device compliances
query (str, optional) – The query to filter results.
- Returns:
List of Device Compliances
- Return type:
[dict]
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> benchmark_set = cb.select(ComplianceBenchmark).first() >>> rules = benchmark_set.get_rule_compliance_devices("BCCAAACA-F0BE-4C0F-BE0A-A09FC1641EE2")
- get_rule_compliances(query='')
Fetches rule compliance summaries associated with the benchmark set.
- Required Permissions:
complianceAssessment.data(READ)
- Parameters:
query (str, optional) – The query to filter results.
- Returns:
List of Rule Compliances
- Return type:
[dict]
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> benchmark_set = cb.select(ComplianceBenchmark).first() >>> rules = benchmark_set.get_rule_compliance()
- get_rules(rule_id=None)
Fetches compliance rules associated with the benchmark set.
- Required Permissions:
complianceAssessment.data(READ)
- Parameters:
rule_id (str, optional) – The rule ID to fetch a specific rule. Defaults to None.
- Returns:
List of Benchmark Rules
- Return type:
[dict]
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> benchmark_set = cb.select(ComplianceBenchmark).first() >>> # To return all rules within a benchmark set, leave get_rules empty. >>> rules = benchmark_set.get_rules()
- get_sections()
Get Sections of the Benchmark Set.
- Required Permissions:
complianceAssessment.data(READ)
- Returns:
List of sections within the Benchmark Set.
- Return type:
list[dict]
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> benchmark = cb.select(ComplianceBenchmark).first() >>> for section in benchmark.get_sections(): ... print(section.section_name, section.section_id)
- refresh()
Reload this object from the server.
- static set_compliance_schedule(cb, scan_schedule, scan_timezone)
Sets the compliance scan schedule and timezone for the organization.
- Required Permissions:
complianceAssessment.data(UPDATE)
- Parameters:
cb (CBCloudAPI) – An instance of CBCloudAPI representing the Carbon Black Cloud API.
scan_schedule (str) – The scan schedule, specified in RFC 5545 format. Example: “RRULE:FREQ=DAILY;BYHOUR=17;BYMINUTE=30;BYSECOND=0”.
scan_timezone (str) – The timezone in which the scan will run, specified as a timezone string. Example: “UTC”.
- Raises:
ApiError – If cb is not an instance of CBCloudAPI, or if scan_schedule or scan_timezone are not provided.
- Returns:
The configured organization settings for Compliance Assessment.
- Return type:
dict
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> schedule = ComplianceBenchmark.set_compliance_schedule(cb, scan_schedule="RRULE:FREQ=DAILY;BYHOUR=17;BYMINUTE=30;BYSECOND=0", scan_timezone="UTC") >>> print(schedule)
- to_json()
Return a json object of the response.
- Returns:
The response dictionary representation.
- Return type:
Any
- update_rules(rule_ids, enabled)
Update compliance rules associated with the benchmark set.
- Required Permissions:
complianceAssessment.data(UPDATE)
- Parameters:
rule_ids (list[str]) – The rule IDs to update their enabled/disabled status.
enabled (bool) – Whether the rule is enabled or disabled.
- Returns:
List of Updated Benchmark Rules
- Return type:
[dict]
Example
>>> cb = CBCloudAPI(profile="example_profile") >>> benchmark_set = cb.select(ComplianceBenchmark).first() >>> # To return all rules within a benchmark set, leave get_rules empty. >>> rules = benchmark_set.update_rules(["2A65B63E-89D9-4844-8290-5042FDF2A27B"], True)
- class ComplianceBenchmarkQuery(doc_class, cb)
Bases:
BaseQuery
,QueryBuilderSupportMixin
,CriteriaBuilderSupportMixin
,IterableQueryMixin
,AsyncQueryMixin
A class representing a query for Compliance Benchmark.
Initialize a ComplianceBenchmarkQuery instance.
- Parameters:
doc_class (class) – The document class for this query.
cb (CBCloudAPI) – An instance of CBCloudAPI.
- Returns:
An instance of ComplianceBenchmarkQuery.
- Return type:
- add_criteria(key, newlist)
Add to the criteria on this query with a custom criteria key.
Will overwrite any existing criteria for the specified key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (str or list[str]) – Value or list of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).add_criteria("type", ["CB_ANALYTIC", "WATCHLIST"]) >>> query = api.select(Alert).add_criteria("type", "CB_ANALYTIC")
- all()
Returns all the items of a query as a list.
- Returns:
List of query items
- Return type:
list
- and_(q=None, **kwargs)
Add a conjunctive filter to this query.
- Parameters:
q (Any) – Query string or solrq.Q object
**kwargs (dict) – Arguments to construct a solrq.Q with
- Returns:
This Query object.
- Return type:
- execute_async()
Executes the current query in an asynchronous fashion.
- Returns:
A future representing the query and its results.
- Return type:
Future
- first()
Returns the first item that would be returned as the result of a query.
- Returns:
First query item
- Return type:
obj
- not_(q=None, **kwargs)
Adds a negated filter to this query.
- Parameters:
q (solrq.Q) – Query object.
**kwargs (dict) – Arguments to construct a solrq.Q with.
- Returns:
This Query object.
- Return type:
- one()
Returns the only item that would be returned by a query.
- Returns:
Sole query return item
- Return type:
obj
- Raises:
MoreThanOneResultError – If the query returns more than one item
ObjectNotFoundError – If the query returns zero items
- or_(q=None, **kwargs)
Add a disjunctive filter to this query.
- Parameters:
q (solrq.Q) – Query object.
**kwargs (dict) – Arguments to construct a solrq.Q with.
- Returns:
This Query object.
- Return type:
- sort_by(key, direction='ASC')
Sets the sorting behavior on a query’s results.
- Parameters:
key (str) – The key in the schema to sort by.
direction (str) – The sort order, either “ASC” or “DESC”.
- Returns:
The query with sorting parameters.
- Return type:
- Raises:
ApiError – If an invalid sort direction is specified.
Example
To sort by a field in descending order:
>>> cb = CBCloudAPI(profile="example_profile") >>> benchmark_sets = cb.select(ComplianceBenchmark).sort_by("name", direction="DESC") >>> print(*benchmark_sets)
- update_criteria(key, newlist)
Update the criteria on this query with a custom criteria key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (list) – List of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).update_criteria("my.criteria.key", ["criteria_value"])
Note
Use this method if there is no implemented method for your desired criteria.
- log = <Logger cbc_sdk.workload.compliance_assessment (WARNING)>
Compliance models
NSX Remediation Module
NSX Remediation for Workloads
- class NSXRemediationJob(cb, running_job_ids)
Bases:
object
An object that runs and monitors an NSX Remediation operation.
Creates a new NSXRemediationJob object.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
running_job_ids (list[str]) – The list of running job IDs.
- async_await_result()
Sets up a Future which can be used to wait asynchronously for all running jobs to be completed.
- Required Permissions:
appliances.registration(READ)
- Returns:
A future representing the job and its results.
- Return type:
Future
- await_result()
Waits for all running jobs to be completed and returns the final status.
- Required Permissions:
appliances.registration(READ)
- Returns:
The final status, mapping individual job IDs to status value dicts.
- Return type:
dict
- classmethod start_request(cb, device_ids, tag, set_tag=True)
Starts an NSX Remediation request and returns the job object.
- Required Permissions:
appliances.nsx.remediation(EXECUTE)
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
device_ids (int|list) – The device ID(s) to run the remediation request on.
tag (str) – The NSX tag to apply to specified devices. Valid values are “CB-NSX-Quarantine”, “CB-NSX-Isolate”, and “CB-NSX-Custom”.
set_tag (bool) – True to toggle the specified tag on, False to toggle it off. Default True.
- Returns:
The object representing all running jobs.
- Return type:
- Raises:
ApiError – If the parameters to start the request are incorrect.
ServerError – If the request could not be successfully started.
- property status
Returns the current status.
- Returns:
The current status, mapping individual job IDs to status value dicts.
- Return type:
dict
Sensor Lifecycle Module
Sensor Lifecycle Management for Workloads
- class SensorKit(cb, initial_data=None)
Bases:
UnrefreshableModel
Represents the information about a sensor, including installation file URLs.
- Parameters:
sensor_type – The type of information this sensor is for.
sensor_url – The URL for downloading the sensor installation package.
sensor_config_url – The URL for downloading the sensor configuration information.
error_code – Code for any error that occurred while getting the sensor information.
message – Message for any error that occurred while getting the sensor information.
Initialize the SensorKit object.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
initial_data (dict) – Initial data used to populate the sensor kit data.
- classmethod from_type(cb, device_type, architecture, sensor_type, version)
Helper method used to create a temporary SensorKit object from its four components.
This method CANNOT be used to create an object that will be persisted to the server.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
device_type (str) – Device type to be used. Valid values are “WINDOWS”, “LINUX”, and “MAC”.
architecture (str) – Architecture to be used. Valid values are “32”, “64”, and “OTHER”.
sensor_type (str) – Sensor type to be used. Valid values are “WINDOWS”, “MAC”, “RHEL”, “UBUNTU”, “SUSE”, and “AMAZON_LINUX”.
version (str) – Sensor version number to be used.
- Returns:
A SensorType object with those specified values.
- Return type:
SensorType
- Raises:
ApiError – If an invalid value was used for one of the three limited values.
- get(attrname, default_val=None)
Return an attribute of this object.
- Parameters:
attrname (str) – Name of the attribute to be returned.
default_val (Any) – Default value to be used if the attribute is not set.
- Returns:
The returned attribute value, which may be defaulted.
- Return type:
Any
- classmethod get_config_template(cb)
Retrieve the sample config.ini file with the properties populated from the server.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
- Returns:
Text of the sample configuration file.
- Return type:
str
- refresh()
Reload this object from the server.
- to_json()
Return a json object of the response.
- Returns:
The response dictionary representation.
- Return type:
Any
- class SensorKitQuery(doc_class, cb)
Bases:
BaseQuery
,CriteriaBuilderSupportMixin
,IterableQueryMixin
,AsyncQueryMixin
Query class used to read in SensorKit objects.
Initialize the SensorKitQuery.
- Parameters:
doc_class (class) – The model class that will be returned by this query.
cb (BaseAPI) – Reference to API object used to communicate with the server.
- add_criteria(key, newlist)
Add to the criteria on this query with a custom criteria key.
Will overwrite any existing criteria for the specified key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (str or list[str]) – Value or list of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).add_criteria("type", ["CB_ANALYTIC", "WATCHLIST"]) >>> query = api.select(Alert).add_criteria("type", "CB_ANALYTIC")
- add_sensor_kit_type(skit=None, **kwargs)
Add a sensor kit type to the request.
- Parameters:
skit (SensorKit) – The sensor kit type to be added to the request.
**kwargs (dict) – If skit is None, the keyword arguments ‘device_type’, ‘architecture’, ‘sensor_type’, and ‘version’ are used to create the sensor kit type to be added.
- Returns:
Reference to this object.
- Return type:
- all()
Returns all the items of a query as a list.
- Returns:
List of query items
- Return type:
list
- config_params(params)
Sets the configuration parameters for the sensor kit query request.
- Parameters:
params (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
Reference to this object.
- Return type:
- execute_async()
Executes the current query in an asynchronous fashion.
- Returns:
A future representing the query and its results.
- Return type:
Future
- expires(expiration_date_time)
Sets the expiration date and time for the sensor kit query request.
- Parameters:
expiration_date_time (str) – The time at which the sensor download link will expire, expressed as ISO 8601 UTC.
- Returns:
Reference to this object.
- Return type:
- first()
Returns the first item that would be returned as the result of a query.
- Returns:
First query item
- Return type:
obj
- one()
Returns the only item that would be returned by a query.
- Returns:
Sole query return item
- Return type:
obj
- Raises:
MoreThanOneResultError – If the query returns more than one item
ObjectNotFoundError – If the query returns zero items
- update_criteria(key, newlist)
Update the criteria on this query with a custom criteria key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (list) – List of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).update_criteria("my.criteria.key", ["criteria_value"])
Note
Use this method if there is no implemented method for your desired criteria.
VM Workloads Search Module
Model and Query Classes for VM Workloads Search API
- class AWSComputeResource(cb, model_unique_id, initial_data=None)
Bases:
BaseComputeResource
Models an AWS compute resource.
Initialize the AWSComputeResource object.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
model_unique_id (str) – ID of the alert represented.
initial_data (dict) – Initial data used to populate the alert.
- classmethod bulk_install(cb, compute_resources, sensor_kit_types, config_file=None)
Install a sensor on a list of compute resources.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
compute_resources (list) – A list of ComputeResource objects used to specify compute resources to install sensors on.
sensor_kit_types (list) – A list of SensorKit objects used to specify sensor types to choose from in installation.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- Raises:
NotImplementedError – Always, for BaseComputeResource.
- classmethod bulk_install_by_id(cb, compute_resources, sensor_kit_types, config_file=None)
Install a sensor on a list of compute resources, specified by ID.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
compute_resources (list) – A list of dicts, each of which contains the keys ‘vcenter_uuid’ and ‘compute_resource_id’, specifying the compute resources to install sensors on.
sensor_kit_types (list) – A list of SensorKit objects used to specify sensor types to choose from in installation.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- Raises:
NotImplementedError – Always, for BaseComputeResource.
- get(attrname, default_val=None)
Return an attribute of this object.
- Parameters:
attrname (str) – Name of the attribute to be returned.
default_val (Any) – Default value to be used if the attribute is not set.
- Returns:
The returned attribute value, which may be defaulted.
- Return type:
Any
- install_sensor(sensor_version, config_file=None)
Install a sensor on this compute resource.
- Parameters:
sensor_version (str) – The version number of the sensor to be used.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- Raises:
NotImplementedError – Always, for BaseComputeResource.
- refresh()
Reload this object from the server.
- to_json()
Return a json object of the response.
- Returns:
The response dictionary representation.
- Return type:
Any
- class AWSComputeResourceQuery(doc_class, cb)
Bases:
BaseComputeResourceQuery
Represents a query that is used to locate AWSComputeResource objects.
Initialize the ComputeResourceQuery.
- Parameters:
doc_class (class) – The model class that will be returned by this query.
cb (BaseAPI) – Reference to API object used to communicate with the server.
- add_criteria(key, newlist)
Add to the criteria on this query with a custom criteria key.
Will overwrite any existing criteria for the specified key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (str or list[str]) – Value or list of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).add_criteria("type", ["CB_ANALYTIC", "WATCHLIST"]) >>> query = api.select(Alert).add_criteria("type", "CB_ANALYTIC")
- all()
Returns all the items of a query as a list.
- Returns:
List of query items
- Return type:
list
- and_(q=None, **kwargs)
Add a conjunctive filter to this query.
- Parameters:
q (Any) – Query string or solrq.Q object
**kwargs (dict) – Arguments to construct a solrq.Q with
- Returns:
This Query object.
- Return type:
- download(download_format=None)
Downloads all compute resources matching the specific criteria.
Example
>>> from cbc_sdk import CBCloudAPI >>> from cbc_sdk.workload import VCenterComputeResource >>> cbc = CBCloudAPI() >>> query = cbc.select(VCenterComputeResource).set_os_type(["UBUNTU"]).set_eligibility(["ELIGIBLE"]) >>> query.set_installation_status(["ERROR"]) >>> job = query.download("CSV") >>> job.await_completion() >>> print(job.get_output_as_string())
- Required Permissions:
public.cloud.inventory(READ) or _API.Public.Cloud:Public.cloud.inventory:READ, jobs.status(READ)
- Parameters:
download_format (str) – The download format to be used. Valid values are “JSON” (the default) and “CSV”.
- Returns:
Asynchronous job which will supply the results of the download when they’re complete.
- Return type:
- Raises:
ApiError – If the format specified was not valid, or if the server did not properly return the job.
- exclude_auto_scaling_group_name(auto_scaling_group_name)
Excludes the specified auto scaling group name from appearing in the search results.
- Parameters:
auto_scaling_group_name (list) – List of string auto scaling group names.
- Returns:
This instance.
- Return type:
- exclude_availability_zone(availability_zone)
Excludes the specified availability zone from appearing in the search results.
- Parameters:
availability_zone (list) – List of string availability zones.
- Returns:
This instance.
- Return type:
- exclude_cloud_provider_account_id(cloud_provider_account_id)
Excludes the specified cloud provider account ID from appearing in the search results.
- Parameters:
cloud_provider_account_id (list) – List of string cloud provider account IDs.
- Returns:
This instance.
- Return type:
- exclude_cloud_provider_resource_id(cloud_provider_resource_id)
Excludes the specified cloud provider resource ID from appearing in the search results.
- Parameters:
cloud_provider_resource_id (list) – List of string cloud provider resource IDs.
- Returns:
This instance.
- Return type:
- exclude_cloud_provider_tags(cloud_provider_tags)
Excludes the specified cloud provider tags from appearing in the search results.
- Parameters:
cloud_provider_tags (list) – List of string cloud provider tags.
- Returns:
This instance.
- Return type:
- exclude_id(id_value)
Excludes the specified compute resource ID from appearing in the search results.
- Parameters:
id_value (list) – List of string compute resource IDs.
- Returns:
This instance.
- Return type:
- exclude_installation_status(installation_status)
Excludes the specified installation status from appearing in the search results.
- Parameters:
installation_status (list) – List of string installation statuses.
- Returns:
This instance.
- Return type:
- exclude_name(name)
Excludes the specified compute resource name from appearing in the search results.
- Parameters:
name (list) – List of string compute resource names.
- Returns:
This instance.
- Return type:
- exclude_platform(platform)
Excludes the specified platform from appearing in the search results.
- Parameters:
platform (list) – List of string platforms.
- Returns:
This instance.
- Return type:
- exclude_platform_details(platform_details)
Excludes the specified platform details from appearing in the search results.
- Parameters:
platform_details (list) – List of string platform details.
- Returns:
This instance.
- Return type:
- exclude_region(region)
Excludes the specified region from appearing in the search results.
- Parameters:
region (list) – List of string regions.
- Returns:
This instance.
- Return type:
- exclude_subnet_id(subnet_id)
Excludes the specified subnet ID from appearing in the search results.
- Parameters:
subnet_id (list) – List of string subnet IDs.
- Returns:
This instance.
- Return type:
- exclude_virtual_private_cloud_id(virtual_private_cloud_id)
Excludes the specified virtual private cloud ID from appearing in the search results.
- Parameters:
virtual_private_cloud_id (list) – List of string virtual private cloud IDs.
- Returns:
This instance.
- Return type:
- execute_async()
Executes the current query in an asynchronous fashion.
- Returns:
A future representing the query and its results.
- Return type:
Future
- facet(fields, rows=None)
Facets all compute resources matching the specified criteria and returns the facet results.
Example
>>> from cbc_sdk import CBCloudAPI >>> from cbc_sdk.workload import AWSComputeResource >>> cbc = CBCloudAPI() >>> query = cbc.select(AWSComputeResource) >>> facets = query.facet(['platform', 'virtual_private_cloud_id'])
- Required Permissions:
public.cloud.inventory(READ) or _API.Public.Cloud:Public.cloud.inventory:READ
- Parameters:
fields (list[str]) – List of the fields to be faceted on.
rows (int) – Number of the top entries to return. Default is 20.
- Returns:
The facet data.
- Return type:
list[ComputeResourceFacet]
- first()
Returns the first item that would be returned as the result of a query.
- Returns:
First query item
- Return type:
obj
- not_(q=None, **kwargs)
Adds a negated filter to this query.
- Parameters:
q (solrq.Q) – Query object.
**kwargs (dict) – Arguments to construct a solrq.Q with.
- Returns:
This Query object.
- Return type:
- one()
Returns the only item that would be returned by a query.
- Returns:
Sole query return item
- Return type:
obj
- Raises:
MoreThanOneResultError – If the query returns more than one item
ObjectNotFoundError – If the query returns zero items
- or_(q=None, **kwargs)
Add a disjunctive filter to this query.
- Parameters:
q (solrq.Q) – Query object.
**kwargs (dict) – Arguments to construct a solrq.Q with.
- Returns:
This Query object.
- Return type:
- set_auto_scaling_group_name(auto_scaling_group_name)
Restricts the search that this query is performed on to the specified auto scaling group name.
- Parameters:
auto_scaling_group_name (list) – List of string auto scaling group names.
- Returns:
This instance.
- Return type:
- set_availability_zone(availability_zone)
Restricts the search that this query is performed on to the specified availability zone.
- Parameters:
availability_zone (list) – List of string availability zones.
- Returns:
This instance.
- Return type:
- set_cloud_provider_account_id(cloud_provider_account_id)
Restricts the search that this query is performed on to the specified cloud provider account ID.
- Parameters:
cloud_provider_account_id (list) – List of string cloud provider account IDs.
- Returns:
This instance.
- Return type:
- set_cloud_provider_resource_id(cloud_provider_resource_id)
Restricts the search that this query is performed on to the specified cloud provider resource ID.
- Parameters:
cloud_provider_resource_id (list) – List of string cloud provider resource IDs.
- Returns:
This instance.
- Return type:
- set_cloud_provider_tags(cloud_provider_tags)
Restricts the search that this query is performed on to the specified cloud provider tags.
- Parameters:
cloud_provider_tags (list) – List of string cloud provider tags.
- Returns:
This instance.
- Return type:
- set_id(id_value)
Restricts the search that this query is performed on to the specified compute resource ID.
- Parameters:
id_value (list) – List of string compute resource IDs.
- Returns:
This instance.
- Return type:
- set_installation_status(installation_status)
Restricts the search that this query is performed on to the specified installation status.
- Parameters:
installation_status (list) – List of string installation statuses.
- Returns:
This instance.
- Return type:
- set_name(name)
Restricts the search that this query is performed on to the specified compute resource name.
- Parameters:
name (list) – List of string compute resource names.
- Returns:
This instance.
- Return type:
- set_platform(platform)
Restricts the search that this query is performed on to the specified platform.
- Parameters:
platform (list) – List of string platforms.
- Returns:
This instance.
- Return type:
- set_platform_details(platform_details)
Restricts the search that this query is performed on to the specified platform details.
- Parameters:
platform_details (list) – List of string platform details.
- Returns:
This instance.
- Return type:
- set_region(region)
Restricts the search that this query is performed on to the specified region.
- Parameters:
region (list) – List of string regions.
- Returns:
This instance.
- Return type:
- set_subnet_id(subnet_id)
Restricts the search that this query is performed on to the specified subnet ID.
- Parameters:
subnet_id (list) – List of string subnet IDs.
- Returns:
This instance.
- Return type:
- set_virtual_private_cloud_id(virtual_private_cloud_id)
Restricts the search that this query is performed on to the specified virtual private cloud ID.
- Parameters:
virtual_private_cloud_id (list) – List of string virtual private cloud IDs.
- Returns:
This instance.
- Return type:
- sort_by(key, direction='ASC')
Sets the sorting behavior on a query’s results.
Example
>>> cb.select(ComputeResource).sort_by("name")
- Parameters:
key (str) – The key in the schema to sort by.
direction (str) – The sort order.
- Returns:
This instance.
- Return type:
- summarize(summary_fields)
Get compute resource summaries on required fields of the resources with the specified criteria.
Example
>>> from cbc_sdk import CBCloudAPI >>> from cbc_sdk.workload import AWSComputeResource >>> cbc = CBCloudAPI() >>> query = cbc.select(AWSComputeResource) >>> summary = query.summarize(['availability_zone', 'region', 'virtual_private_cloud_id'])
- Required Permissions:
public.cloud.inventory(READ) or _API.Public.Cloud:Public.cloud.inventory:READ
- Parameters:
summary_fields (list[str]) – The fields to be summarized.
- Returns:
A mapping of field names to the number of resources with that field.
- Return type:
map[str, int]
- update_criteria(key, newlist)
Update the criteria on this query with a custom criteria key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (list) – List of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).update_criteria("my.criteria.key", ["criteria_value"])
Note
Use this method if there is no implemented method for your desired criteria.
- class BaseComputeResource(cb, model_unique_id, initial_data=None)
Bases:
NewBaseModel
Internal BaseComputeResource model
Initialize the BaseComputeResource object.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
model_unique_id (str) – ID of the compute resource represented.
initial_data (dict) – Initial data used to populate the resource object.
- classmethod bulk_install(cb, compute_resources, sensor_kit_types, config_file=None)
Install a sensor on a list of compute resources.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
compute_resources (list) – A list of ComputeResource objects used to specify compute resources to install sensors on.
sensor_kit_types (list) – A list of SensorKit objects used to specify sensor types to choose from in installation.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- Raises:
NotImplementedError – Always, for BaseComputeResource.
- classmethod bulk_install_by_id(cb, compute_resources, sensor_kit_types, config_file=None)
Install a sensor on a list of compute resources, specified by ID.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
compute_resources (list) – A list of dicts, each of which contains the keys ‘vcenter_uuid’ and ‘compute_resource_id’, specifying the compute resources to install sensors on.
sensor_kit_types (list) – A list of SensorKit objects used to specify sensor types to choose from in installation.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- Raises:
NotImplementedError – Always, for BaseComputeResource.
- get(attrname, default_val=None)
Return an attribute of this object.
- Parameters:
attrname (str) – Name of the attribute to be returned.
default_val (Any) – Default value to be used if the attribute is not set.
- Returns:
The returned attribute value, which may be defaulted.
- Return type:
Any
- install_sensor(sensor_version, config_file=None)
Install a sensor on this compute resource.
- Parameters:
sensor_version (str) – The version number of the sensor to be used.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- Raises:
NotImplementedError – Always, for BaseComputeResource.
- refresh()
Reload this object from the server.
- to_json()
Return a json object of the response.
- Returns:
The response dictionary representation.
- Return type:
Any
- class BaseComputeResourceQuery(doc_class, cb)
Bases:
BaseQuery
,QueryBuilderSupportMixin
,CriteriaBuilderSupportMixin
,IterableQueryMixin
,AsyncQueryMixin
Base class for compute resource queries, not intended for direct use.
Initialize the BaseComputeResourceQuery.
- Parameters:
doc_class (class) – The model class that will be returned by this query.
cb (BaseAPI) – Reference to API object used to communicate with the server.
- add_criteria(key, newlist)
Add to the criteria on this query with a custom criteria key.
Will overwrite any existing criteria for the specified key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (str or list[str]) – Value or list of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).add_criteria("type", ["CB_ANALYTIC", "WATCHLIST"]) >>> query = api.select(Alert).add_criteria("type", "CB_ANALYTIC")
- all()
Returns all the items of a query as a list.
- Returns:
List of query items
- Return type:
list
- and_(q=None, **kwargs)
Add a conjunctive filter to this query.
- Parameters:
q (Any) – Query string or solrq.Q object
**kwargs (dict) – Arguments to construct a solrq.Q with
- Returns:
This Query object.
- Return type:
- download(download_format=None)
Downloads all compute resources matching the specific criteria.
Example
>>> from cbc_sdk import CBCloudAPI >>> from cbc_sdk.workload import VCenterComputeResource >>> cbc = CBCloudAPI() >>> query = cbc.select(VCenterComputeResource).set_os_type(["UBUNTU"]).set_eligibility(["ELIGIBLE"]) >>> query.set_installation_status(["ERROR"]) >>> job = query.download("CSV") >>> job.await_completion() >>> print(job.get_output_as_string())
- Required Permissions:
public.cloud.inventory(READ) or _API.Public.Cloud:Public.cloud.inventory:READ, jobs.status(READ)
- Parameters:
download_format (str) – The download format to be used. Valid values are “JSON” (the default) and “CSV”.
- Returns:
Asynchronous job which will supply the results of the download when they’re complete.
- Return type:
- Raises:
ApiError – If the format specified was not valid, or if the server did not properly return the job.
- execute_async()
Executes the current query in an asynchronous fashion.
- Returns:
A future representing the query and its results.
- Return type:
Future
- facet(fields, rows=None)
Facets all compute resources matching the specified criteria and returns the facet results.
Example
>>> from cbc_sdk import CBCloudAPI >>> from cbc_sdk.workload import AWSComputeResource >>> cbc = CBCloudAPI() >>> query = cbc.select(AWSComputeResource) >>> facets = query.facet(['platform', 'virtual_private_cloud_id'])
- Required Permissions:
public.cloud.inventory(READ) or _API.Public.Cloud:Public.cloud.inventory:READ
- Parameters:
fields (list[str]) – List of the fields to be faceted on.
rows (int) – Number of the top entries to return. Default is 20.
- Returns:
The facet data.
- Return type:
list[ComputeResourceFacet]
- first()
Returns the first item that would be returned as the result of a query.
- Returns:
First query item
- Return type:
obj
- not_(q=None, **kwargs)
Adds a negated filter to this query.
- Parameters:
q (solrq.Q) – Query object.
**kwargs (dict) – Arguments to construct a solrq.Q with.
- Returns:
This Query object.
- Return type:
- one()
Returns the only item that would be returned by a query.
- Returns:
Sole query return item
- Return type:
obj
- Raises:
MoreThanOneResultError – If the query returns more than one item
ObjectNotFoundError – If the query returns zero items
- or_(q=None, **kwargs)
Add a disjunctive filter to this query.
- Parameters:
q (solrq.Q) – Query object.
**kwargs (dict) – Arguments to construct a solrq.Q with.
- Returns:
This Query object.
- Return type:
- sort_by(key, direction='ASC')
Sets the sorting behavior on a query’s results.
Example
>>> cb.select(ComputeResource).sort_by("name")
- Parameters:
key (str) – The key in the schema to sort by.
direction (str) – The sort order.
- Returns:
This instance.
- Return type:
- update_criteria(key, newlist)
Update the criteria on this query with a custom criteria key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (list) – List of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).update_criteria("my.criteria.key", ["criteria_value"])
Note
Use this method if there is no implemented method for your desired criteria.
- class ComputeResourceFacet(cb, model_unique_id, initial_data=None)
Bases:
UnrefreshableModel
Facet data returned by the facet() method of the query.
Initialize the ComputeResourceFacet object.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
model_unique_id (str) – ID of the facet represented.
initial_data (dict) – Initial data used to populate the facet.
- class ComputeResourceFacetValue(cb, model_unique_id, initial_data=None)
Bases:
UnrefreshableModel
Represents a single facet value inside a ComputeResourceFacet.
Initialize the ComputeResourceFacetValue object.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
model_unique_id (str) – ID of the facet value represented.
initial_data (dict) – Initial data used to populate the facet value.
- get(attrname, default_val=None)
Return an attribute of this object.
- Parameters:
attrname (str) – Name of the attribute to be returned.
default_val (Any) – Default value to be used if the attribute is not set.
- Returns:
The returned attribute value, which may be defaulted.
- Return type:
Any
- refresh()
Reload this object from the server.
- to_json()
Return a json object of the response.
- Returns:
The response dictionary representation.
- Return type:
Any
- get(attrname, default_val=None)
Return an attribute of this object.
- Parameters:
attrname (str) – Name of the attribute to be returned.
default_val (Any) – Default value to be used if the attribute is not set.
- Returns:
The returned attribute value, which may be defaulted.
- Return type:
Any
- refresh()
Reload this object from the server.
- to_json()
Return a json object of the response.
- Returns:
The response dictionary representation.
- Return type:
Any
- property values
Returns the values for this particular facet.
- Returns:
The values of this facet.
- Return type:
- class VCenterComputeResource(cb, model_unique_id, initial_data=None)
Bases:
BaseComputeResource
Models a vCenter compute resource.
Initialize the VCenterComputeResource object.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
model_unique_id (str) – ID of the alert represented.
initial_data (dict) – Initial data used to populate the alert.
- classmethod bulk_install(cb, compute_resources, sensor_kit_types, config_file=None)
Install a sensor on a list of compute resources.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
compute_resources (list) – A list of ComputeResource objects used to specify compute resources to install sensors on.
sensor_kit_types (list) – A list of SensorKit objects used to specify sensor types to choose from in installation.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- classmethod bulk_install_by_id(cb, compute_resources, sensor_kit_types, config_file=None)
Install a sensor on a list of compute resources, specified by ID.
- Parameters:
cb (BaseAPI) – Reference to API object used to communicate with the server.
compute_resources (list) – A list of dicts, each of which contains the keys ‘vcenter_uuid’ and ‘compute_resource_id’, specifying the compute resources to install sensors on.
sensor_kit_types (list) – A list of SensorKit objects used to specify sensor types to choose from in installation.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- get(attrname, default_val=None)
Return an attribute of this object.
- Parameters:
attrname (str) – Name of the attribute to be returned.
default_val (Any) – Default value to be used if the attribute is not set.
- Returns:
The returned attribute value, which may be defaulted.
- Return type:
Any
- install_sensor(sensor_version, config_file=None)
Install a sensor on this compute resource.
- Parameters:
sensor_version (str) – The version number of the sensor to be used.
config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
- Returns:
A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
- Return type:
dict
- Raises:
ApiError – If the compute node is not eligible or is of an invalid type.
- refresh()
Reload this object from the server.
- to_json()
Return a json object of the response.
- Returns:
The response dictionary representation.
- Return type:
Any
- class VCenterComputeResourceQuery(doc_class, cb)
Bases:
BaseComputeResourceQuery
Represents a query that is used to locate ComputeResource objects.
Initialize the ComputeResourceQuery.
- Parameters:
doc_class (class) – The model class that will be returned by this query.
cb (BaseAPI) – Reference to API object used to communicate with the server.
- add_criteria(key, newlist)
Add to the criteria on this query with a custom criteria key.
Will overwrite any existing criteria for the specified key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (str or list[str]) – Value or list of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).add_criteria("type", ["CB_ANALYTIC", "WATCHLIST"]) >>> query = api.select(Alert).add_criteria("type", "CB_ANALYTIC")
- all()
Returns all the items of a query as a list.
- Returns:
List of query items
- Return type:
list
- and_(q=None, **kwargs)
Add a conjunctive filter to this query.
- Parameters:
q (Any) – Query string or solrq.Q object
**kwargs (dict) – Arguments to construct a solrq.Q with
- Returns:
This Query object.
- Return type:
- download(download_format=None)
Downloads all compute resources matching the specific criteria.
Example
>>> from cbc_sdk import CBCloudAPI >>> from cbc_sdk.workload import VCenterComputeResource >>> cbc = CBCloudAPI() >>> query = cbc.select(VCenterComputeResource).set_os_type(["UBUNTU"]).set_eligibility(["ELIGIBLE"]) >>> query.set_installation_status(["ERROR"]) >>> job = query.download("CSV") >>> job.await_completion() >>> print(job.get_output_as_string())
- Required Permissions:
public.cloud.inventory(READ) or _API.Public.Cloud:Public.cloud.inventory:READ, jobs.status(READ)
- Parameters:
download_format (str) – The download format to be used. Valid values are “JSON” (the default) and “CSV”.
- Returns:
Asynchronous job which will supply the results of the download when they’re complete.
- Return type:
- Raises:
ApiError – If the format specified was not valid, or if the server did not properly return the job.
- exclude_appliance_uuid(appliance_uuid)
Excludes the specified appliance UUID from appearing in the search results.
- Parameters:
appliance_uuid (list) – List of string appliance uuids.
- Returns:
This instance.
- Return type:
- exclude_cluster_name(cluster_name)
Excludes the specified cluster name from appearing in the search results.
- Parameters:
cluster_name (list) – List of string cluster names.
- Returns:
This instance.
- Return type:
- exclude_datacenter_name(datacenter_name)
Excludes the specified datacenter name from appearing in the search results.
- Parameters:
datacenter_name (list) – List of string datacenter names.
- Returns:
This instance.
- Return type:
- exclude_device_guid(device_guid)
Excludes the specified device GUID from appearing in the search results.
- Parameters:
device_guid (list) – List of string device GUIDs.
- Returns:
This instance.
- Return type:
- exclude_eligibility(eligibility)
Excludes the specified eligibility from appearing in the search results.
- Parameters:
eligibility (list) – List of string eligibilities.
- Returns:
This instance.
- Return type:
- exclude_eligibility_code(eligibility_code)
Excludes the specified eligibility code from appearing in the search results.
- Parameters:
eligibility_code (list) – List of string eligibility codes.
- Returns:
This instance.
- Return type:
- exclude_esx_host_name(esx_host_name)
Excludes the specified ESX host name from appearing in the search results.
- Parameters:
esx_host_name (list) – List of string ESX host names.
- Returns:
This instance.
- Return type:
- exclude_esx_host_uuid(esx_host_uuid)
Excludes the specified ESX host UUID from appearing in the search results.
- Parameters:
esx_host_uuid (list) – List of string ESX host UUIDs.
- Returns:
This instance.
- Return type:
- exclude_host_name(host_name)
Excludes the specified host name from appearing in the search results.
- Parameters:
host_name (list) – List of string host names.
- Returns:
This instance.
- Return type:
- exclude_installation_status(installation_status)
Excludes the specified installation status from appearing in the search results.
- Parameters:
installation_status (list) – List of string installation statuses.
- Returns:
This instance.
- Return type:
- exclude_installation_type(installation_type)
Excludes the specified installation type from appearing in the search results.
- Parameters:
installation_type (list) – List of string installation types.
- Returns:
This instance.
- Return type:
- exclude_ip_address(ip_address)
Excludes the specified IP address from appearing in the search results.
- Parameters:
ip_address (list) – List of string IP addresses.
- Returns:
This instance.
- Return type:
- exclude_name(name)
Excludes the specified name from appearing in the search results.
- Parameters:
name (list) – List of string names.
- Returns:
This instance.
- Return type:
- exclude_os_architecture(os_architecture)
Excludes the specified OS architecture from appearing in the search results.
- Parameters:
os_architecture (list) – List of string OS architectures.
- Returns:
This instance.
- Return type:
- exclude_os_description(os_description)
Excludes the specified OS description from appearing in the search results.
- Parameters:
os_description (list) – List of string OS descriptions.
- Returns:
This instance.
- Return type:
- exclude_os_type(os_type)
Excludes the specified OS type from appearing in the search results.
- Parameters:
os_type (list) – List of string OS types.
- Returns:
This instance.
- Return type:
- exclude_registration_id(registration_id)
Excludes the specified registration ID from appearing in the search results.
- Parameters:
registration_id (list) – List of string registration IDs.
- Returns:
This instance.
- Return type:
- exclude_uuid(uuid)
Excludes the specified UUID from appearing in the search results.
- Parameters:
uuid (list) – List of string UUIDs.
- Returns:
This instance.
- Return type:
- exclude_vcenter_host_url(vcenter_host_url)
Excludes the specified vCenter host URL from appearing in the search results.
- Parameters:
vcenter_host_url (list) – List of string vCenter host URLs.
- Returns:
This instance.
- Return type:
- exclude_vcenter_name(vcenter_name)
Excludes the specified vCenter name from appearing in the search results.
- Parameters:
vcenter_name (list) – List of string vCenter names.
- Returns:
This instance.
- Return type:
- exclude_vcenter_uuid(vcenter_uuid)
Excludes the specified vCenter UUID from appearing in the search results.
- Parameters:
vcenter_uuid (list) – List of string vCenter UUIDs.
- Returns:
This instance.
- Return type:
- exclude_vmwaretools_version(vmwaretools_version)
Excludes the specified VMware Tools version from appearing in the search results.
- Parameters:
vmwaretools_version (list) – List of string VMware Tools versions.
- Returns:
This instance.
- Return type:
- execute_async()
Executes the current query in an asynchronous fashion.
- Returns:
A future representing the query and its results.
- Return type:
Future
- facet(fields, rows=None)
Facets all compute resources matching the specified criteria and returns the facet results.
Example
>>> from cbc_sdk import CBCloudAPI >>> from cbc_sdk.workload import AWSComputeResource >>> cbc = CBCloudAPI() >>> query = cbc.select(AWSComputeResource) >>> facets = query.facet(['platform', 'virtual_private_cloud_id'])
- Required Permissions:
public.cloud.inventory(READ) or _API.Public.Cloud:Public.cloud.inventory:READ
- Parameters:
fields (list[str]) – List of the fields to be faceted on.
rows (int) – Number of the top entries to return. Default is 20.
- Returns:
The facet data.
- Return type:
list[ComputeResourceFacet]
- first()
Returns the first item that would be returned as the result of a query.
- Returns:
First query item
- Return type:
obj
- not_(q=None, **kwargs)
Adds a negated filter to this query.
- Parameters:
q (solrq.Q) – Query object.
**kwargs (dict) – Arguments to construct a solrq.Q with.
- Returns:
This Query object.
- Return type:
- one()
Returns the only item that would be returned by a query.
- Returns:
Sole query return item
- Return type:
obj
- Raises:
MoreThanOneResultError – If the query returns more than one item
ObjectNotFoundError – If the query returns zero items
- or_(q=None, **kwargs)
Add a disjunctive filter to this query.
- Parameters:
q (solrq.Q) – Query object.
**kwargs (dict) – Arguments to construct a solrq.Q with.
- Returns:
This Query object.
- Return type:
- set_appliance_uuid(appliance_uuid)
Restricts the search that this query is performed on to the specified appliance uuid.
- Parameters:
appliance_uuid (list) – List of string appliance uuids.
- Returns:
This instance.
- Return type:
- set_cluster_name(cluster_name)
Restricts the search that this query is performed on to the specified cluster name.
- Parameters:
cluster_name (list) – List of string cluster names.
- Returns:
This instance.
- Return type:
- set_datacenter_name(datacenter_name)
Restricts the search that this query is performed on to the specified datacenter name.
- Parameters:
datacenter_name (list) – List of string datacenter names.
- Returns:
This instance.
- Return type:
- set_device_guid(device_guid)
Restricts the search that this query is performed on to the specified device GUID.
- Parameters:
device_guid (list) – List of string device GUIDs.
- Returns:
This instance.
- Return type:
- set_eligibility(eligibility)
Restricts the search that this query is performed on to the specified eligibility.
- Parameters:
eligibility (list) – List of string eligibilities.
- Returns:
This instance.
- Return type:
- set_eligibility_code(eligibility_code)
Restricts the search that this query is performed on to the specified eligibility code.
- Parameters:
eligibility_code (list) – List of string eligibility codes.
- Returns:
This instance.
- Return type:
- set_esx_host_name(esx_host_name)
Restricts the search that this query is performed on to the specified ESX host name.
- Parameters:
esx_host_name (list) – List of string ESX host names.
- Returns:
This instance.
- Return type:
- set_esx_host_uuid(esx_host_uuid)
Restricts the search that this query is performed on to the specified ESX host UUID.
- Parameters:
esx_host_uuid (list) – List of string ESX host UUIDs.
- Returns:
This instance.
- Return type:
- set_host_name(host_name)
Restricts the search that this query is performed on to the specified host name.
- Parameters:
host_name (list) – List of string host names.
- Returns:
This instance.
- Return type:
- set_installation_status(installation_status)
Restricts the search that this query is performed on to the specified installation status.
- Parameters:
installation_status (list) – List of string installation status.
- Returns:
This instance.
- Return type:
- set_installation_type(installation_type)
Restricts the search that this query is performed on to the specified installation type.
- Parameters:
installation_type (list) – List of string installation types.
- Returns:
This instance.
- Return type:
- set_ip_address(ip_address)
Restricts the search that this query is performed on to the specified ip address.
- Parameters:
ip_address (list) – List of string ip addresses.
- Returns:
This instance.
- Return type:
- set_name(name)
Restricts the search that this query is performed on to the specified name.
- Parameters:
name (list) – List of string names.
- Returns:
This instance.
- Return type:
- set_os_architecture(os_architecture)
Restricts the search that this query is performed on to the specified os architecture.
- Parameters:
os_architecture (list) – List of string os architecture.
- Returns:
This instance.
- Return type:
- set_os_description(os_description)
Restricts the search that this query is performed on to the specified os description.
- Parameters:
os_description (list) – List of string os description.
- Returns:
This instance.
- Return type:
- set_os_type(os_type)
Restricts the search that this query is performed on to the specified os type.
- Parameters:
os_type (list) – List of string os type.
- Returns:
This instance.
- Return type:
- set_registration_id(registration_id)
Restricts the search that this query is performed on to the specified registration ID.
- Parameters:
registration_id (list) – List of string registration IDs.
- Returns:
This instance.
- Return type:
- set_uuid(uuid)
Restricts the search that this query is performed on to the specified uuid.
- Parameters:
uuid (list) – List of string uuid.
- Returns:
This instance.
- Return type:
- set_vcenter_host_url(vcenter_host_url)
Restricts the search that this query is performed on to the specified vCenter host URL.
- Parameters:
vcenter_host_url (list) – List of string vCenter host URLs.
- Returns:
This instance.
- Return type:
- set_vcenter_name(vcenter_name)
Restricts the search that this query is performed on to the specified vCenter name.
- Parameters:
vcenter_name (list) – List of string vCenter names.
- Returns:
This instance.
- Return type:
- set_vcenter_uuid(vcenter_uuid)
Restricts the search that this query is performed on to the specified vCenter UUID.
- Parameters:
vcenter_uuid (list) – List of string vCenter UUIDs.
- Returns:
This instance.
- Return type:
- set_vmwaretools_version(vmwaretools_version)
Restricts the search that this query is performed on to the specified VMware Tools version.
- Parameters:
vmwaretools_version (list) – List of string VMware Tools versions.
- Returns:
This instance.
- Return type:
- sort_by(key, direction='ASC')
Sets the sorting behavior on a query’s results.
Example
>>> cb.select(ComputeResource).sort_by("name")
- Parameters:
key (str) – The key in the schema to sort by.
direction (str) – The sort order.
- Returns:
This instance.
- Return type:
- update_criteria(key, newlist)
Update the criteria on this query with a custom criteria key.
- Parameters:
key (str) – The key for the criteria item to be set.
newlist (list) – List of values to be set for the criteria item.
- Returns:
The query object with specified custom criteria.
Example
>>> query = api.select(Alert).update_criteria("my.criteria.key", ["criteria_value"])
Note
Use this method if there is no implemented method for your desired criteria.
- log = <Logger cbc_sdk.workload.vm_workloads_search (WARNING)>
Workloads Search model