Method: exportAssets

Exports assets with time and resource types to a given Cloud Storage location. The output format is newline-delimited JSON. This API implements the google.longrunning.Operation API allowing you to keep track of the export.

HTTP request

POST https://cloudasset.googleapis.com/v1/{parent=*/*}:exportAssets

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. The relative name of the root asset. This can only be an organization number (such as "organizations/123"), a project ID (such as "projects/my-project-id"), or a project number (such as "projects/12345"), or a folder number (such as "folders/123").

Authorization requires one or more of the following Google IAM permissions on the specified resource parent:

  • cloudasset.assets.exportResource
  • cloudasset.assets.exportIamPolicy

Request body

The request body contains data with the following structure:

JSON representation
{
  "readTime": string,
  "assetTypes": [
    string
  ],
  "contentType": enum (ContentType),
  "outputConfig": {
    object (OutputConfig)
  }
}
Fields
readTime

string (Timestamp format)

timestamp to take an asset snapshot. This can only be set to a timestamp between 2018-10-02 UTC (inclusive) and the current time. If not specified, the current time will be used. Due to delays in resource data collection and indexing, there is a volatile window during which running the same query may get different results.

A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

assetTypes[]

string

A list of asset types of which to take a snapshot for. For example: "compute.googleapis.com/Disk". If specified, only matching assets will be returned. See Introduction to Cloud Asset Inventory for all supported asset types.

contentType

enum (ContentType)

Asset content type. If not specified, no content but the asset name will be returned.

outputConfig

object (OutputConfig)

Required. Output configuration indicating where the results will be output to. All results will be in newline delimited JSON format.

Response body

If successful, the response body contains an instance of Operation.

Authorization Scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Authentication Overview.

OutputConfig

Output configuration for export assets destination.

JSON representation
{

  // Union field destination can be only one of the following:
  "gcsDestination": {
    object (GcsDestination)
  },
  "bigqueryDestination": {
    object (BigQueryDestination)
  }
  // End of list of possible types for union field destination.
}
Fields
Union field destination. Asset export destination. destination can be only one of the following:
gcsDestination

object (GcsDestination)

Destination on Cloud Storage.

bigqueryDestination

object (BigQueryDestination)

Destination on BigQuery. The output table stores the fields in asset proto as columns in BigQuery. The resource/iamPolicy field is converted to a record with each field to a column, except metadata to a single JSON string.

GcsDestination

A Cloud Storage location.

JSON representation
{

  // Union field object_uri can be only one of the following:
  "uri": string,
  "uriPrefix": string
  // End of list of possible types for union field object_uri.
}
Fields
Union field object_uri. Required. object_uri can be only one of the following:
uri

string

The uri of the Cloud Storage object. It's the same uri that is used by gsutil. For example: "gs://bucketName/objectName". See Viewing and Editing Object metadata for more information.

uriPrefix

string

The uri prefix of all generated Cloud Storage objects. For example: "gs://bucketName/objectNamePrefix". Each object uri is in format: "gs://bucketName/objectNamePrefix// and only contains assets for that type. starts from 0. For example: "gs://bucketName/objectNamePrefix/compute.googleapis.com/Disk/0" is the first shard of output objects containing all compute.googleapis.com/Disk assets. An INVALID_ARGUMENT error will be returned if file with the same name "gs://bucketName/objectNamePrefix" already exists.

BigQueryDestination

A BigQuery destination.

JSON representation
{
  "dataset": string,
  "table": string,
  "force": boolean
}
Fields
dataset

string

Required. The BigQuery dataset in format "projects/projectId/datasets/datasetId", to which the snapshot result should be exported. If this dataset does not exist, the export call returns an error.

table

string

Required. The BigQuery table to which the snapshot result should be written. If this table does not exist, a new table with the given name will be created.

force

boolean

If the destination table already exists and this flag is TRUE, the table will be overwritten by the contents of assets snapshot. If the flag is not set and the destination table already exists, the export call returns an error.

Try it!

หน้านี้มีประโยชน์ไหม โปรดแสดงความคิดเห็น