Assets_write¶
Table of Contents
Client¶
-
class
Assets_write.Client¶ A client object representing ‘Assets_write’ Service:
import almdrlib client = almdrlib.client('assets_write')
Available methods:
-
asset_group(**kwargs)¶ Creates an
asset-groupasset.Delete an existing
asset-groupasset.Updates an existing
asset-groupasset.Request Syntax
response = client.asset_group( account_id='string' data='dict' )
- Parameters
account_id (string) –
[REQUIRED]
The AIMS account ID whose assets are being accessed. Only valid account IDs are acceptable. Invalid account IDs result in an
HTTP 404 Not FoundorHTTP 403 Forbidden, depending on the client’s access level.data (dict) –
- Return type
dict
- Returns
Response Syntax
'dict'Response Definitions
-
declare(**kwargs)¶ Declares (creates) a region and a network (an alias for VPC) with relationship to the region and with a claim key.
declare_applicationscreates a set of assets of type"application"and adds relationships to the target asset, specified by thetypeandkeyparameters. If such asset doesn’t exist, then declare_applications returns a HTTP 404 response. Declaring applications overwrites any existing applications of the same scope for that asset. declare_applications returns a HTTP 204 response upon success.Declares (creates) a deployment (née environment) in assets.
The request must contain the environment’s parameters in a JSON structure with the key items detailed below.
Creates vulnerabilities and remediations and adds relationships to the asset which is vulnerable, specified by the
typeandkeyparameters. If such asset doesn’t exist, then declare_vulnerabilities returns a HTTP 404 response. Declaring vulnerabilities overwrites any existing vulnerabilities of the same scope for that asset.accumulates agents and appliances statistics. The accumulate operation may be called any number of times for the same asset. The updated asset will contain a statistics property with sub-properties for each accumulated statistic. This is intended to record collection statistics based on defined strategy by collection type on agent and appliance assets. Currently, only
hourlystrategy is supported. Hourly strategy records the last 24 calendar hours.Note that the response
last_hourvalue is the previous hour, not the current hour value.last_dayrepresents the sum of the all previous hours but the current hour.Declares access levels for the assets specified. If
asset,destination, or any ofderives_fromassets don’t exist, then declare_access_levels returns anHTTP 404response.declare_assetcreates or merges an asset and its relationships. declare_asset may be called any number of times for the same asset, with subsets of properties and relationships, and the assets service will merge the data. If a relationship is declared to an asset that doesn’t exist, this asset will not be returned by assets_query until it is declared.declareproperties [merges properties](#api--merge-properties) with an existing asset. All fields are required, except
conditionsandcreate. This operation returns a HTTP/2 201 code on success.The following algorithm applies when calling
declare_propertieson a non-existent asset:Apply the operation if the
createproperty in the request body istrueDiscard the operation if the
createproperty in the request body isfalseApply the operation if there is no
createproperty in the request body, but theconditionsproperty is presentDiscard the operation if both the
createandconditionsproperties are not present in the request body
The following algorithm applies when calling
declare_propertieson an existing asset:Test conditions against the asset
If
conditionsis not present in the request body, or is present and the value is an empty list, apply the operationif
conditionsis present and at least one condition is presentIf all conditions are satisfied, apply the operation
If at least one condition is not satisfied, discard the operation and return a 304 status code
If, when applying the operation, a version mismatch is hit, retry the operation including the conditions evaluation and resulting behaviours
There are two classes of conditions: presence tests and comparisons. All conditions require
propertyfield, which holds the name of the property being tested, andtypefield, which defines the test to be applied. Comparisons also must providevaluefield with value to compare existing data to.The following presence tests are defined:
"if-defined"- check whether existing asset has the property being tested"if-undefined"- check whether existing asset doesn’t have that property
Following comparisons are defined:
"if-equal"- true if existing asset has the property being tested and its value is equal to the given one"if-not-equal"- true if existing asset’s value of the property being tested is not equal to the given one or existing asset has no such property"if-less"- true if existing asset’s value of the property being tested is less than the given one or existing asset has no such property"if-less-or-equal"- true if existing asset’s value of the property being tested is less than or equal to the given one or existing asset has no such property"if-greater"- true if existing asset’s value of the property being tested is greater than the given one or existing asset has no such property"if-greater-or-equal"- true if existing asset’s value of the property being tested is greater than or equal to the given one or existing asset has no such property
declare_relationshipscreates or merges relationships for an existing asset. Callingdeclare_relationshipson a non-existent asset will return a 404.Deletes an existing asset and its relationships.
Deletes multiple existing assets and their relationships.
Completely removes the given properties (or nested properties) from the given asset.
Deletes specific relationships for an existing asset.
Request Syntax
response = client.declare( account_id='string' data='dict' deployment_id='string' )
- Parameters
account_id (string) –
[REQUIRED]
The AIMS account ID whose assets are being accessed. Only valid account IDs are acceptable. Invalid account IDs result in an
HTTP 404 Not FoundorHTTP 403 Forbidden, depending on the client’s access level.data (dict) –
deployment_id (string) –
[REQUIRED]
The ID of the deployment source as represented in the deployments service (uppercase UUID).
- Return type
dict
- Returns
Response Syntax
'dict'Response Definitions
-
declare_batch(**kwargs)¶ Declares a list of any combination of
declare_asset,declare_properties,remove_properties,remove_relationships, anddeclare_relationshipsoperations. Batch operations on the same asset with the same scope may be combined into a single operation. Note that you should avoid batching operations that could result in different outcomes if applied in a different order, for instance, you must not declare and remove the same properties or relationships in different operations on the same asset in the same batch. Currently, the API may accept it but in the future this behavior will be rejected.Request Syntax
response = client.declare_batch( account_id='string' deployment_id='string' operation='batch_declare' operations=[ {} ] transaction='False|True' )
- Parameters
account_id (string) –
[REQUIRED]
The AIMS account ID whose assets are being accessed. Only valid account IDs are acceptable. Invalid account IDs result in an
HTTP 404 Not FoundorHTTP 403 Forbidden, depending on the client’s access level.deployment_id (string) –
[REQUIRED]
The ID of the deployment source as represented in the deployments service (uppercase UUID).
operation (string) –
[REQUIRED]
This must be
batch_declare.Valid values:
batch_declareoperations (list) –
[REQUIRED]
Any combination of
declare_asset,declare_properties,remove_properties,remove_relationships, anddeclare_relationshipsoperations. Batch operations on the same asset with the same scope may be combined into a single operation. Note that you should avoid batching operations that could result in different outcomes if applied in a different order, for instance, you must not declare and remove the same properties or relationships in different operations on the same asset in the same batch. Currently, the API may accept it but in the future this behavior will be rejected.(dict) –
transaction (boolean) – If batch declare is issued with transaction flag enabled all operations run sequentially and the batch will fail (abort on spot) as soon as any of the declares is unsuccessful. No rollback is performed. For operations that failed “not executed” error will be returned (see example). Default:
false.
- Return type
dict
- Returns
Response Syntax
{ 'return_values': [ { 'code': 'integer', 'value': {} } ] }
Response Definitions
return_values (list) –
(dict) –
code (integer) –
HTML response code (e.g. 201, 400, 404, 413)
value (dict) –
The operation resulting object (e.g Declare Asset response)
-