// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * Storage Batch Operations API Client for Deno * ============================================ * * * * Docs: https://cloud.google.com/storage/docs/batch-operations/overview * Source: https://googleapis.deno.dev/v1/storagebatchoperations:v1.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; export class StorageBatchOperations { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://storagebatchoperations.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * Gets information about a location. * * @param name Resource name for the location. */ async projectsLocationsGet(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return data as Location; } /** * Gets a BucketOperation. * * @param name Required. The `name` of the bucket operation to retrieve. Format: `projects/{project_id}/locations/global/jobs/{job_id}/bucketOperations/{bucket_operation_id}`. */ async projectsLocationsJobsBucketOperationsGet(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeBucketOperation(data); } /** * Lists BucketOperations in a given project and job. * * @param parent Required. Format: `projects/{project_id}/locations/global/jobs/{job_id}`. */ async projectsLocationsJobsBucketOperationsList(parent: string, opts: ProjectsLocationsJobsBucketOperationsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/bucketOperations`); if (opts.filter !== undefined) { url.searchParams.append("filter", String(opts.filter)); } if (opts.orderBy !== undefined) { url.searchParams.append("orderBy", String(opts.orderBy)); } if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeListBucketOperationsResponse(data); } /** * Cancels a batch job. * * @param name Required. The `name` of the job to cancel. Format: `projects/{project_id}/locations/global/jobs/{job_id}`. */ async projectsLocationsJobsCancel(name: string, req: CancelJobRequest): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }:cancel`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as CancelJobResponse; } /** * Creates a batch job. * * @param parent Required. The value for parent. */ async projectsLocationsJobsCreate(parent: string, req: Job, opts: ProjectsLocationsJobsCreateOptions = {}): Promise { req = serializeJob(req); const url = new URL(`${this.#baseUrl}v1/${ parent }/jobs`); if (opts.jobId !== undefined) { url.searchParams.append("jobId", String(opts.jobId)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Operation; } /** * Deletes a batch job. * * @param name Required. The `name` of the job to delete. Format: `projects/{project_id}/locations/global/jobs/{job_id}`. */ async projectsLocationsJobsDelete(name: string, opts: ProjectsLocationsJobsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.force !== undefined) { url.searchParams.append("force", String(opts.force)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Empty; } /** * Gets a batch job. * * @param name Required. The `name` of the job to retrieve. Format: `projects/{project_id}/locations/global/jobs/{job_id}`. */ async projectsLocationsJobsGet(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeJob(data); } /** * Lists Jobs in a given project. * * @param parent Required. Format: projects/{project_id}/locations/global. */ async projectsLocationsJobsList(parent: string, opts: ProjectsLocationsJobsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/jobs`); if (opts.filter !== undefined) { url.searchParams.append("filter", String(opts.filter)); } if (opts.orderBy !== undefined) { url.searchParams.append("orderBy", String(opts.orderBy)); } if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeListJobsResponse(data); } /** * Lists information about the supported locations for this service. This * method lists locations based on the resource scope provided in the * ListLocationsRequest.name field: * **Global locations**: If `name` is * empty, the method lists the public locations available to all projects. * * **Project-specific locations**: If `name` follows the format * `projects/{project}`, the method lists locations visible to that specific * project. This includes public, private, or other project-specific locations * enabled for the project. For gRPC and client library implementations, the * resource name is passed as the `name` field. For direct service calls, the * resource name is incorporated into the request path based on the specific * service implementation and version. * * @param name The resource that owns the locations collection, if applicable. */ async projectsLocationsList(name: string, opts: ProjectsLocationsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }/locations`); if (opts.extraLocationTypes !== undefined) { url.searchParams.append("extraLocationTypes", String(opts.extraLocationTypes)); } if (opts.filter !== undefined) { url.searchParams.append("filter", String(opts.filter)); } if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as ListLocationsResponse; } /** * Starts asynchronous cancellation on a long-running operation. The server * makes a best effort to cancel the operation, but success is not guaranteed. * If the server doesn't support this method, it returns * `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or * other methods to check whether the cancellation succeeded or whether the * operation completed despite cancellation. On successful cancellation, the * operation is not deleted; instead, it becomes an operation with an * Operation.error value with a google.rpc.Status.code of `1`, corresponding * to `Code.CANCELLED`. * * @param name The name of the operation resource to be cancelled. */ async projectsLocationsOperationsCancel(name: string, req: CancelOperationRequest): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }:cancel`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Empty; } /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the * operation. If the server doesn't support this method, it returns * `google.rpc.Code.UNIMPLEMENTED`. * * @param name The name of the operation resource to be deleted. */ async projectsLocationsOperationsDelete(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Empty; } /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. * * @param name The name of the operation resource. */ async projectsLocationsOperationsGet(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return data as Operation; } /** * Lists operations that match the specified filter in the request. If the * server doesn't support this method, it returns `UNIMPLEMENTED`. * * @param name The name of the operation's parent resource. */ async projectsLocationsOperationsList(name: string, opts: ProjectsLocationsOperationsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }/operations`); if (opts.filter !== undefined) { url.searchParams.append("filter", String(opts.filter)); } if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.returnPartialSuccess !== undefined) { url.searchParams.append("returnPartialSuccess", String(opts.returnPartialSuccess)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as ListOperationsResponse; } } /** * Represents updates to existing access-control entries on an object. */ export interface AccessControlsUpdates { /** * Optional. Grants to add or update. If a grant for same entity exists, its * role is updated. */ grants?: ObjectAccessControl[]; /** * Optional. Entities for which all grants should be removed. An entity can't * be in both `grants` and `remove_entities`. */ removeEntities?: string[]; } /** * Describes configuration of a single bucket and its objects to be * transformed. */ export interface Bucket { /** * Required. Bucket name for the objects to be transformed. */ bucket?: string; /** * Specifies objects in a manifest file. */ manifest?: Manifest; /** * Specifies objects matching a prefix set. */ prefixList?: PrefixList; } /** * Describes list of buckets and their objects to be transformed. */ export interface BucketList { /** * Required. List of buckets and their objects to be transformed. You can * specify only one bucket per job. If multiple buckets are specified, an * error occurs. */ buckets?: Bucket[]; } /** * BucketOperation represents a bucket-level breakdown of a Job. */ export interface BucketOperation { /** * The bucket name of the objects to be transformed in the BucketOperation. */ bucketName?: string; /** * Output only. The time that the BucketOperation was completed. */ readonly completeTime?: Date; /** * Output only. Information about the progress of the bucket operation. */ readonly counters?: Counters; /** * Output only. The time that the BucketOperation was created. */ readonly createTime?: Date; /** * Delete objects. */ deleteObject?: DeleteObject; /** * Output only. Summarizes errors encountered with sample error log entries. */ readonly errorSummaries?: ErrorSummary[]; /** * Specifies objects in a manifest file. */ manifest?: Manifest; /** * Identifier. The resource name of the BucketOperation. This is defined by * the service. Format: * `projects/{project_id}/locations/global/jobs/{job_id}/bucketOperations/{bucket_operation}`. */ name?: string; /** * Specifies objects matching a prefix set. */ prefixList?: PrefixList; /** * Specifies objects matching the object filters in a project source. */ projectSource?: ProjectSource; /** * Updates object metadata. Allows updating fixed-key and custom metadata and * fixed-key metadata i.e. Cache-Control, Content-Disposition, * Content-Encoding, Content-Language, Content-Type, Custom-Time. */ putMetadata?: PutMetadata; /** * Changes object hold status. */ putObjectHold?: PutObjectHold; /** * Rewrite the object and updates metadata like KMS key. */ rewriteObject?: RewriteObject; /** * Updates object ACLs. */ setObjectAcls?: SetObjectAcls; /** * Output only. The time that the BucketOperation was started. */ readonly startTime?: Date; /** * Output only. State of the BucketOperation. */ readonly state?: | "STATE_UNSPECIFIED" | "QUEUED" | "RUNNING" | "SUCCEEDED" | "CANCELED" | "FAILED"; /** * Update object custom context. */ updateObjectCustomContext?: UpdateObjectCustomContext; } function serializeBucketOperation(data: any): BucketOperation { return { ...data, projectSource: data["projectSource"] !== undefined ? serializeProjectSource(data["projectSource"]) : undefined, }; } function deserializeBucketOperation(data: any): BucketOperation { return { ...data, completeTime: data["completeTime"] !== undefined ? new Date(data["completeTime"]) : undefined, createTime: data["createTime"] !== undefined ? new Date(data["createTime"]) : undefined, errorSummaries: data["errorSummaries"] !== undefined ? data["errorSummaries"].map((item: any) => (deserializeErrorSummary(item))) : undefined, projectSource: data["projectSource"] !== undefined ? deserializeProjectSource(data["projectSource"]) : undefined, startTime: data["startTime"] !== undefined ? new Date(data["startTime"]) : undefined, }; } /** * Message for Job to Cancel */ export interface CancelJobRequest { /** * Optional. An optional request ID to identify requests. Specify a unique * request ID in case you need to retry your request. Requests with same * `request_id` are ignored for at least 60 minutes since the first request. * The request ID must be a valid UUID with the exception that zero UUID isn't * supported (00000000-0000-0000-0000-000000000000). */ requestId?: string; } /** * Message for response to cancel Job. */ export interface CancelJobResponse { } /** * The request message for Operations.CancelOperation. */ export interface CancelOperationRequest { } /** * Describes details about the progress of the job. */ export interface Counters { /** * Output only. The number of objects that failed due to user errors or * service errors. */ readonly failedObjectCount?: bigint; /** * Output only. Number of object custom contexts created. This field is only * populated for jobs with the UpdateObjectCustomContext transformation. */ readonly objectCustomContextsCreated?: bigint; /** * Output only. Number of object custom contexts deleted. This field is only * populated for jobs with the UpdateObjectCustomContext transformation. */ readonly objectCustomContextsDeleted?: bigint; /** * Output only. Number of object custom contexts updated. This counter tracks * custom contexts where the key already existed, but the payload was * modified. This field is only populated for jobs with the * UpdateObjectCustomContext transformation. */ readonly objectCustomContextsUpdated?: bigint; /** * Output only. Number of objects completed. */ readonly succeededObjectCount?: bigint; /** * Output only. Number of bytes found from source. This field is only * populated for jobs with a prefix list object configuration. */ readonly totalBytesFound?: bigint; /** * Output only. The total number of bytes affected by the transformation. For * example, this counts bytes deleted for `DeleteObject` operations and bytes * rewritten for `RewriteObject` operations. */ readonly totalBytesTransformed?: bigint; /** * Output only. Number of objects listed. */ readonly totalObjectCount?: bigint; } /** * Describes a collection of updates to apply to custom contexts identified by * key. */ export interface CustomContextUpdates { /** * Optional. Custom contexts to clear by key. A key can't be present in both * `updates` and `keys_to_clear`. */ keysToClear?: string[]; /** * Optional. Insert or update the existing custom contexts. */ updates?: { [key: string]: ObjectCustomContextPayload }; } /** * Describes options to delete an object. */ export interface DeleteObject { /** * Required. Controls deletion behavior when versioning is enabled for the * object's bucket. If true, both live and noncurrent objects will be * permanently deleted. Otherwise live objects in versioned buckets will * become noncurrent and objects that were already noncurrent will be skipped. * This setting doesn't have any impact on the Soft Delete feature. All * objects deleted by this service can be be restored for the duration of the * Soft Delete retention duration if enabled. If enabled and the manifest * doesn't specify an object's generation, a `GetObjectMetadata` call is made * to determine the live object generation. */ permanentObjectDeletionEnabled?: boolean; } /** * A generic empty message that you can re-use to avoid defining duplicated * empty messages in your APIs. A typical example is to use it as the request or * the response type of an API method. For instance: service Foo { rpc * Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } */ export interface Empty { } /** * An entry describing an error that has occurred. */ export interface ErrorLogEntry { /** * Optional. Output only. At most 5 error log entries are recorded for a * given error code for a job. */ readonly errorDetails?: string[]; /** * Required. Output only. Object URL. e.g. gs://my_bucket/object.txt */ readonly objectUri?: string; } /** * A summary of errors by error code, plus a count and sample error log * entries. */ export interface ErrorSummary { /** * Required. The canonical error code. */ errorCode?: | "OK" | "CANCELLED" | "UNKNOWN" | "INVALID_ARGUMENT" | "DEADLINE_EXCEEDED" | "NOT_FOUND" | "ALREADY_EXISTS" | "PERMISSION_DENIED" | "UNAUTHENTICATED" | "RESOURCE_EXHAUSTED" | "FAILED_PRECONDITION" | "ABORTED" | "OUT_OF_RANGE" | "UNIMPLEMENTED" | "INTERNAL" | "UNAVAILABLE" | "DATA_LOSS"; /** * Required. Number of errors encountered per `error_code`. */ errorCount?: bigint; /** * Required. Sample error logs. */ errorLogEntries?: ErrorLogEntry[]; } function serializeErrorSummary(data: any): ErrorSummary { return { ...data, errorCount: data["errorCount"] !== undefined ? String(data["errorCount"]) : undefined, }; } function deserializeErrorSummary(data: any): ErrorSummary { return { ...data, errorCount: data["errorCount"] !== undefined ? BigInt(data["errorCount"]) : undefined, }; } /** * Represents a textual expression in the Common Expression Language (CEL) * syntax. CEL is a C-like expression language. The syntax and semantics of CEL * are documented at https://github.com/google/cel-spec. Example (Comparison): * title: "Summary size limit" description: "Determines if a summary is less * than 100 chars" expression: "document.summary.size() < 100" Example * (Equality): title: "Requestor is owner" description: "Determines if requestor * is the document owner" expression: "document.owner == * request.auth.claims.email" Example (Logic): title: "Public documents" * description: "Determine whether the document should be publicly visible" * expression: "document.type != 'private' && document.type != 'internal'" * Example (Data Manipulation): title: "Notification string" description: * "Create a notification string with a timestamp." expression: "'New message * received at ' + string(document.create_time)" The exact variables and * functions that may be referenced within an expression are determined by the * service that evaluates it. See the service documentation for additional * information. */ export interface Expr { /** * Optional. Description of the expression. This is a longer text which * describes the expression, e.g. when hovered over it in a UI. */ description?: string; /** * Textual representation of an expression in Common Expression Language * syntax. */ expression?: string; /** * Optional. String indicating the location of the expression for error * reporting, e.g. a file name and a position in the file. */ location?: string; /** * Optional. Title for the expression, i.e. a short string describing its * purpose. This can be used e.g. in UIs which allow to enter the expression. */ title?: string; } /** * The storage batch operations job description. */ export interface Job { /** * Specifies a list of buckets and their objects to be transformed. */ bucketList?: BucketList; /** * Output only. The time that the job was completed. */ readonly completeTime?: Date; /** * Output only. Information about the progress of the job. */ readonly counters?: Counters; /** * Output only. The time that the job was created. */ readonly createTime?: Date; /** * Delete objects. */ deleteObject?: DeleteObject; /** * Optional. A user-provided description for the job. Maximum length: 1024 * bytes when unicode-encoded. */ description?: string; /** * Optional. If true, the job runs in dry run mode, returning the total * object count and, if the object configuration is a prefix list, the bytes * found from source. No transformations are performed. */ dryRun?: boolean; /** * Output only. Summarizes errors encountered with sample error log entries. */ readonly errorSummaries?: ErrorSummary[]; /** * Output only. If true, this job operates on multiple buckets. Multi-bucket * jobs are subject to different quota limits than single-bucket jobs. */ readonly isMultiBucketJob?: boolean; /** * Optional. Logging configuration. */ loggingConfig?: LoggingConfig; /** * Identifier. The resource name of the job. Format: * `projects/{project_id}/locations/global/jobs/{job_id}`. For example: * `projects/123456/locations/global/jobs/job01`. `job_id` is unique in a * given project. */ name?: string; /** * Specifies a project source and filters to identify objects to be * transformed. */ projectSource?: ProjectSource; /** * Updates object metadata. Allows updating fixed-key and custom metadata. * For example, `Cache-Control`, `Content-Disposition`, `Content-Encoding`, * `Content-Language`, `Content-Type`, `Custom-Time`, and `Retention * configuration`. */ putMetadata?: PutMetadata; /** * Changes object hold status. */ putObjectHold?: PutObjectHold; /** * Rewrite the object and updates metadata like KMS key. */ rewriteObject?: RewriteObject; /** * Output only. The time that the job was scheduled. */ readonly scheduleTime?: Date; /** * Updates object ACLs. */ setObjectAcls?: SetObjectAcls; /** * Output only. State of the job. */ readonly state?: | "STATE_UNSPECIFIED" | "RUNNING" | "SUCCEEDED" | "CANCELED" | "FAILED" | "QUEUED"; /** * Update object custom context. */ updateObjectCustomContext?: UpdateObjectCustomContext; } function serializeJob(data: any): Job { return { ...data, projectSource: data["projectSource"] !== undefined ? serializeProjectSource(data["projectSource"]) : undefined, }; } function deserializeJob(data: any): Job { return { ...data, completeTime: data["completeTime"] !== undefined ? new Date(data["completeTime"]) : undefined, createTime: data["createTime"] !== undefined ? new Date(data["createTime"]) : undefined, errorSummaries: data["errorSummaries"] !== undefined ? data["errorSummaries"].map((item: any) => (deserializeErrorSummary(item))) : undefined, projectSource: data["projectSource"] !== undefined ? deserializeProjectSource(data["projectSource"]) : undefined, scheduleTime: data["scheduleTime"] !== undefined ? new Date(data["scheduleTime"]) : undefined, }; } /** * Message for response to listing BucketOperations */ export interface ListBucketOperationsResponse { /** * A list of storage batch bucket operations. */ bucketOperations?: BucketOperation[]; /** * A token identifying a page of results. */ nextPageToken?: string; /** * Locations that could not be reached. */ unreachable?: string[]; } function serializeListBucketOperationsResponse(data: any): ListBucketOperationsResponse { return { ...data, bucketOperations: data["bucketOperations"] !== undefined ? data["bucketOperations"].map((item: any) => (serializeBucketOperation(item))) : undefined, }; } function deserializeListBucketOperationsResponse(data: any): ListBucketOperationsResponse { return { ...data, bucketOperations: data["bucketOperations"] !== undefined ? data["bucketOperations"].map((item: any) => (deserializeBucketOperation(item))) : undefined, }; } /** * Message for response to listing Jobs */ export interface ListJobsResponse { /** * A list of storage batch jobs. */ jobs?: Job[]; /** * A token identifying a page of results. */ nextPageToken?: string; /** * Locations that could not be reached. */ unreachable?: string[]; } function serializeListJobsResponse(data: any): ListJobsResponse { return { ...data, jobs: data["jobs"] !== undefined ? data["jobs"].map((item: any) => (serializeJob(item))) : undefined, }; } function deserializeListJobsResponse(data: any): ListJobsResponse { return { ...data, jobs: data["jobs"] !== undefined ? data["jobs"].map((item: any) => (deserializeJob(item))) : undefined, }; } /** * The response message for Locations.ListLocations. */ export interface ListLocationsResponse { /** * A list of locations that matches the specified filter in the request. */ locations?: Location[]; /** * The standard List next-page token. */ nextPageToken?: string; } /** * The response message for Operations.ListOperations. */ export interface ListOperationsResponse { /** * The standard List next-page token. */ nextPageToken?: string; /** * A list of operations that matches the specified filter in the request. */ operations?: Operation[]; /** * Unordered list. Unreachable resources. Populated when the request sets * `ListOperationsRequest.return_partial_success` and reads across * collections. For example, when attempting to list all resources across all * supported locations. */ unreachable?: string[]; } /** * A resource that represents a Google Cloud location. */ export interface Location { /** * The friendly name for this location, typically a nearby city name. For * example, "Tokyo". */ displayName?: string; /** * Cross-service attributes for the location. For example * {"cloud.googleapis.com/region": "us-east1"} */ labels?: { [key: string]: string }; /** * The canonical id for this location. For example: `"us-east1"`. */ locationId?: string; /** * Service-specific metadata. For example the available capacity at the given * location. */ metadata?: { [key: string]: any }; /** * Resource name for the location, which may vary between implementations. * For example: `"projects/example-project/locations/us-east1"` */ name?: string; } /** * Specifies the Cloud Logging behavior. */ export interface LoggingConfig { /** * Required. Specifies the actions to be logged. */ logActions?: | "LOGGABLE_ACTION_UNSPECIFIED" | "TRANSFORM"[]; /** * Required. States in which Action are logged.If empty, no logs are * generated. */ logActionStates?: | "LOGGABLE_ACTION_STATE_UNSPECIFIED" | "SUCCEEDED" | "FAILED"[]; } /** * Describes list of objects to be transformed. */ export interface Manifest { /** * Required. Specify the manifest file location. The format of manifest * location can be an absolute path to the object in the format of * `gs://bucket_name/path/object_name`. For example, * `gs://bucket_name/path/object_name.csv`. Alternatively, you can specify an * absolute path with a single wildcard character in the file name, for * example `gs://bucket_name/path/file_name*.csv`. If the manifest location is * specified with a wildcard, objects in all manifest files matching the * pattern will be acted upon. The manifest is a CSV file, uploaded to Cloud * Storage, that contains one object or a list of objects that you want to * process. Each row in the manifest must include the `bucket` and `name` of * the object. You can optionally specify the `generation` of the object. If * you don't specify the `generation`, the current version of the object is * used. You can optionally include a header row with the following format: * `bucket,name,generation`. For example, bucket,name,generation * bucket_1,object_1,generation_1 bucket_1,object_2,generation_2 * bucket_1,object_3,generation_3 Note: The manifest file must specify only * objects within the bucket provided to the job. Rows referencing objects in * other buckets are ignored. */ manifestLocation?: string; } /** * Represents an access control entry on an object. */ export interface ObjectAccessControl { /** * Required. The entity holding the permission, in one of the following * forms: * `allUsers` * `allAuthenticatedUsers` */ entity?: string; /** * Required. The role to grant. Acceptable values are: * `READER` - gives * read access to the object. * `OWNER` - gives owner access to the object. */ role?: string; } /** * Describes the payload of a user-defined object custom context. */ export interface ObjectCustomContextPayload { /** * The value of the object custom context. If set, `value` can't be an empty * string because it is a required field in custom context. If unset, `value` * is ignored and no changes are made to the `value` field of the custom * context payload. */ value?: string; } /** * Describes options for object retention update. */ export interface ObjectRetention { /** * Required. The object's retention expiration time, during which, the object * is protected from being deleted or overwritten. The time must be specified * in RFC 3339 format, for example `YYYY-MM-DD'T'HH:MM:SS'Z'` or * `YYYY-MM-DD'T'HH:MM:SS.SS'Z'`. To clear an object's retention, both * `retentionMode` and `retainUntilTime` must be left unset (omitted). Setting * `retentionMode` to `RETENTION_MODE_UNSPECIFIED` is treated as a no-op. * Unlike an unset field, it doesn't modify or clear the retention settings. */ retainUntilTime?: string; /** * Required. The retention mode. */ retentionMode?: | "RETENTION_MODE_UNSPECIFIED" | "LOCKED" | "UNLOCKED"; } /** * This resource represents a long-running operation that is the result of a * network API call. */ export interface Operation { /** * If the value is `false`, it means the operation is still in progress. If * `true`, the operation is completed, and either `error` or `response` is * available. */ done?: boolean; /** * The error result of the operation in case of failure or cancellation. */ error?: Status; /** * Service-specific metadata associated with the operation. It typically * contains progress information and common metadata such as create time. Some * services might not provide such metadata. Any method that returns a * long-running operation should document the metadata type, if any. */ metadata?: { [key: string]: any }; /** * The server-assigned name, which is only unique within the same service * that originally returns it. If you use the default HTTP mapping, the `name` * should be a resource name ending with `operations/{unique_id}`. */ name?: string; /** * The normal, successful response of the operation. If the original method * returns no data on success, such as `Delete`, the response is * `google.protobuf.Empty`. If the original method is standard * `Get`/`Create`/`Update`, the response should be the resource. For other * methods, the response should have the type `XxxResponse`, where `Xxx` is * the original method name. For example, if the original method name is * `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. */ response?: { [key: string]: any }; } /** * Represents the metadata of the long-running operation. */ export interface OperationMetadata { /** * Output only. API version used to start the operation. */ readonly apiVersion?: string; /** * Output only. The time the operation was created. */ readonly createTime?: Date; /** * Output only. The time the operation finished running. */ readonly endTime?: Date; /** * Output only. The Job associated with the operation. */ readonly job?: Job; /** * Output only. The unique operation resource name. Format: * projects/{project_id}/locations/global/operations/{operation}. */ readonly operation?: string; /** * Output only. Identifies whether the user has requested cancellation of the * operation. Operations that have been cancelled successfully have * google.longrunning.Operation.error value with a google.rpc.Status.code of * 1, corresponding to `Code.CANCELLED`. */ readonly requestedCancellation?: boolean; } /** * Describes prefixes of objects to be transformed. */ export interface PrefixList { /** * Optional. Specify one or more object prefixes. For example: * To match one * object, use a single prefix, `prefix1`. * To match multiple objects, use * comma-separated prefixes, `prefix1, prefix2`. * To match all objects, use * an empty prefix, `''` */ includedObjectPrefixes?: string[]; } /** * Additional options for * StorageBatchOperations#projectsLocationsJobsBucketOperationsList. */ export interface ProjectsLocationsJobsBucketOperationsListOptions { /** * Optional. Filters results as defined by https://google.aip.dev/160. */ filter?: string; /** * Optional. Field to sort by. Supported fields are `name` and `create_time`. */ orderBy?: string; /** * Optional. The list page size. Default page size is 100. */ pageSize?: number; /** * Optional. The list page token. */ pageToken?: string; } /** * Additional options for StorageBatchOperations#projectsLocationsJobsCreate. */ export interface ProjectsLocationsJobsCreateOptions { /** * Required. A unique identifier for the job. `job_id` must be up to 128 * characters and must include only characters available in DNS names, as * defined by RFC-1123. */ jobId?: string; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID in case you need to retry your request. Requests with same * `request_id` are ignored for at least 60 minutes since the first request. * The request ID must be a valid UUID with the exception that zero UUID isn't * supported (00000000-0000-0000-0000-000000000000). */ requestId?: string; } /** * Additional options for StorageBatchOperations#projectsLocationsJobsDelete. */ export interface ProjectsLocationsJobsDeleteOptions { /** * Optional. If set to true, any child bucket operations of the job are * deleted. We recommend setting this to `true`. You can't mutate bucket * operations directly, so only the `jobs.delete` permission is required to * delete a job (and its child bucket operations). */ force?: boolean; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID in case you need to retry your request. Requests with same * `request_id` are ignored for at least 60 minutes since the first request. * The request ID must be a valid UUID with the exception that zero UUID isn't * supported (00000000-0000-0000-0000-000000000000). */ requestId?: string; } /** * Additional options for StorageBatchOperations#projectsLocationsJobsList. */ export interface ProjectsLocationsJobsListOptions { /** * Optional. Filters results as defined by https://google.aip.dev/160. */ filter?: string; /** * Optional. Field to sort by. Supported fields are `name` and `create_time`. */ orderBy?: string; /** * Optional. The list page size. The default page size is 100. */ pageSize?: number; /** * Optional. The list page token. */ pageToken?: string; } /** * Additional options for StorageBatchOperations#projectsLocationsList. */ export interface ProjectsLocationsListOptions { /** * Optional. Do not use this field unless explicitly documented otherwise. * This is primarily for internal usage. */ extraLocationTypes?: string; /** * A filter to narrow down results to a preferred subset. The filtering * language accepts strings like `"displayName=tokyo"`, and is documented in * more detail in [AIP-160](https://google.aip.dev/160). */ filter?: string; /** * The maximum number of results to return. If not set, the service selects a * default. */ pageSize?: number; /** * A page token received from the `next_page_token` field in the response. * Send that page token to receive the subsequent page. */ pageToken?: string; } /** * Additional options for * StorageBatchOperations#projectsLocationsOperationsList. */ export interface ProjectsLocationsOperationsListOptions { /** * The standard list filter. */ filter?: string; /** * The standard list page size. */ pageSize?: number; /** * The standard list page token. */ pageToken?: string; /** * When set to `true`, operations that are reachable are returned as normal, * and those that are unreachable are returned in the * ListOperationsResponse.unreachable field. This can only be `true` when * reading across collections. For example, when `parent` is set to * `"projects/example/locations/-"`. This field is not supported by default * and will result in an `UNIMPLEMENTED` error if set unless explicitly * documented otherwise in service or product specific documentation. */ returnPartialSuccess?: boolean; } /** * Describes the project source where the objects satisfying the filters will * be transformed. */ export interface ProjectSource { /** * Optional. Filters expressed in Common Expression Language (CEL) to apply * to buckets to identify buckets with objects to be transformed. */ bucketFilters?: Expr; /** * Optional. The unique identifier of a dry run job to use as the baseline * for the current job. Specifying this ID ensures the job is executed against * the same set of objects validated during the dry run. The value corresponds * to the {job_id} segment of the resource name: * `projects/{project_id}/locations/{location}/jobs/{job_id}`. */ dryRunJobId?: string; /** * Required. The resource identifier of the Storage Insights dataset * configuration. Storage batch operations uses the latest snapshot from this * dataset as the source to list and filter target objects. Format: * `projects/{project_id}/locations/{location}/datasetConfigs/{dataset_config}`. */ insightsDatasetConfig?: string; /** * Optional. Filters expressed in Common Expression Language (CEL) to apply * to objects to identify objects to be transformed. */ objectFilters?: Expr; /** * Required. Project name of the objects to be transformed. e.g. * projects/my-project or projects/123456. */ project?: string; /** * Output only. The snapshot time used by the job to read the Storage * Insights dataset for bucket and object discovery. This field is populated * by the service and reflects the exact timestamp of the dataset snapshot * used. */ readonly snapshotTime?: Date; /** * Optional. Specifies the Cloud Storage locations to include in the job. If * provided, only buckets and objects within these locations will be * discovered from the Storage Insights dataset as configured in the * `insights_dataset_config`. If omitted, the job will discover buckets and * objects from all locations configured in the `insights_dataset_config`. */ targetLocations?: TargetLocations; } function serializeProjectSource(data: any): ProjectSource { return { ...data, targetLocations: data["targetLocations"] !== undefined ? serializeTargetLocations(data["targetLocations"]) : undefined, }; } function deserializeProjectSource(data: any): ProjectSource { return { ...data, snapshotTime: data["snapshotTime"] !== undefined ? new Date(data["snapshotTime"]) : undefined, targetLocations: data["targetLocations"] !== undefined ? deserializeTargetLocations(data["targetLocations"]) : undefined, }; } /** * Describes options for object metadata update. */ export interface PutMetadata { /** * Optional. Updates the objects `Cache-Control` fixed metadata. Unset values * in the request are ignored. To clear the metadata, set an empty value. * Additionally, the value for `Custom-Time` can't decrease. For details, see * [Cache-Control](https://cloud.google.com/storage/docs/metadata#caching_data). */ cacheControl?: string; /** * Optional. Updates objects `Content-Disposition` fixed metadata. Unset * values in the request are ignored. To clear the metadata, set an empty * value. For details, see * [Content-Disposition](https://cloud.google.com/storage/docs/metadata#content-disposition). */ contentDisposition?: string; /** * Optional. Updates the objects `Content-Encoding` fixed metadata. Unset * values in the request are ignored. To clear the metadata, set an empty * value. For details, see * [Content-Encoding](https://cloud.google.com/storage/docs/metadata#content-encoding). */ contentEncoding?: string; /** * Optional. Updates the objects `Content-Language` fixed metadata. Metadata * values must use ISO 639-1 language codes. The maximum length for metadata * values is 100 characters. Unset values in the request are ignored. To clear * the metadata, set an empty value. For details, see * [Content-Language](https://cloud.google.com/storage/docs/metadata#content-language). */ contentLanguage?: string; /** * Optional. Updates objects `Content-Type` fixed metadata. Unset values in * the request are ignored. To clear the metadata, set an empty value. For * details, see * [Content-Type](https://cloud.google.com/storage/docs/metadata#content-type). */ contentType?: string; /** * Optional. Updates the object's custom metadata. This operation adds or * sets individual custom metadata key-value pairs. Keys specified with empty * values have their values cleared. Existing custom metadata keys not * included in the request remain unchanged. For details, see [Custom * metadata](https://cloud.google.com/storage/docs/metadata#custom-metadata). */ customMetadata?: { [key: string]: string }; /** * Optional. Updates the objects `Custom-Time` fixed metadata. Unset values * in the request are ignored. To clear the metadata, set an empty value. The * time must be specified in RFC 3339 format, for example * `YYYY-MM-DD'T'HH:MM:SS'Z'` or `YYYY-MM-DD'T'HH:MM:SS.SS'Z'`. For details, * see * [Custom-Time](https://cloud.google.com/storage/docs/metadata#custom-time). */ customTime?: string; /** * Optional. Updates an object's retention configuration. To clear an * object's retention, both `retentionMode` and `retainUntilTime` must be left * unset (omitted). Setting `retentionMode` to `RETENTION_MODE_UNSPECIFIED` is * treated as a no-op. Unlike an unset field, it doesn't modify or clear the * retention settings. An object with `LOCKED` retention mode can't have its * retention cleared or its `retainUntilTime` reduced. For more information, * see [Object * retention](https://cloud.google.com/storage/docs/batch-operations/create-manage-batch-operation-jobs#retain-until-time). */ objectRetention?: ObjectRetention; } /** * Describes options to update object hold. */ export interface PutObjectHold { /** * Required. Updates object event based holds state. When object event based * hold is set, object can't be deleted or replaced. Resets object's time in * the bucket for the purposes of the retention period. */ eventBasedHold?: | "HOLD_STATUS_UNSPECIFIED" | "SET" | "UNSET"; /** * Required. Updates object temporary holds state. When object temporary hold * is set, object can't be deleted or replaced. */ temporaryHold?: | "HOLD_STATUS_UNSPECIFIED" | "SET" | "UNSET"; } /** * Describes options for object rewrite. */ export interface RewriteObject { /** * Optional. Resource name of the Cloud KMS key that is used to encrypt the * object. The Cloud KMS key must be located in same location as the object. * For details, see * https://cloud.google.com/storage/docs/encryption/using-customer-managed-keys#add-object-key * Format: * `projects/{project_id}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}` * For example: * `projects/123456/locations/us-central1/keyRings/my-keyring/cryptoKeys/my-key`. * The object will be rewritten and set with the specified KMS key. */ kmsKey?: string; /** * Optional. Rewrites the object to the specified storage class. Setting this * field will perform a full byte copy of the object if the storage class is * different from the object's current storage class. If Autoclass is enabled * on the bucket, storage class changes are ignored by Cloud Storage. */ storageClass?: | "STORAGE_CLASS_UNSPECIFIED" | "STANDARD" | "NEARLINE" | "COLDLINE" | "ARCHIVE"; } /** * Describes options for setting object ACLs. */ export interface SetObjectAcls { /** * Required. Add, update, or remove grants from the object's existing ACLs. */ accessControlsUpdates?: AccessControlsUpdates; } /** * The `Status` type defines a logical error model that is suitable for * different programming environments, including REST APIs and RPC APIs. It is * used by [gRPC](https://github.com/grpc). Each `Status` message contains three * pieces of data: error code, error message, and error details. You can find * out more about this error model and how to work with it in the [API Design * Guide](https://cloud.google.com/apis/design/errors). */ export interface Status { /** * The status code, which should be an enum value of google.rpc.Code. */ code?: number; /** * A list of messages that carry the error details. There is a common set of * message types for APIs to use. */ details?: { [key: string]: any }[]; /** * A developer-facing error message, which should be in English. Any * user-facing error message should be localized and sent in the * google.rpc.Status.details field, or localized by the client. */ message?: string; } /** * Describes the Cloud Storage locations to include in a ProjectSource job. */ export interface TargetLocations { /** * Required. REQUIRED. A list of Cloud Storage locations (e.g., * `us-central1`) to include in the job. If `snapshot_time` is omitted, the * job automatically defaults to the most recent snapshot timestamp that is * successfully populated in BOTH the `object_attributes_view` and * `bucket_attributes_view` across ALL specified locations. For details on * Storage Insights dataset snapshots and views, see: * https://docs.cloud.google.com/storage/docs/insights/dataset-tables-and-schemas#schema */ locations?: string[]; /** * Optional. OPTIONAL. The exact Storage Insights snapshot timestamp to use * for the job compatible with the RFC 3339 format (e.g., * `2024-01-02T03:04:05Z`). If specified, this exact snapshot must exist in * BOTH the `object_attributes_view` and `bucket_attributes_view` for every * location listed in `locations`. If the snapshot is missing from either view * in any of the locations, the job fails. */ snapshotTime?: Date; } function serializeTargetLocations(data: any): TargetLocations { return { ...data, snapshotTime: data["snapshotTime"] !== undefined ? data["snapshotTime"].toISOString() : undefined, }; } function deserializeTargetLocations(data: any): TargetLocations { return { ...data, snapshotTime: data["snapshotTime"] !== undefined ? new Date(data["snapshotTime"]) : undefined, }; } /** * Describes options to update object custom contexts. */ export interface UpdateObjectCustomContext { /** * If set, must be set to true and all existing object custom contexts are * deleted. */ clearAll?: boolean; /** * A collection of updates to apply to specific custom contexts. Use this to * add, update or delete individual contexts by key. */ customContextUpdates?: CustomContextUpdates; }