Try Gemini 1.5 models, the latest multimodal models in Vertex AI, and see what you can build with up to a 2M token context window.
Try Gemini 1.5 models, the latest multimodal models in Vertex AI, and see what you can build with up to a 2M token context window.
Set access control list (ACL)
Stay organized with collections
Save and categorize content based on your preferences.
Set the access control list (ACL) for a document or a project.
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides instructions and code samples for setting the Access Control List (ACL) on either a document or project within Google Cloud's Document AI Warehouse.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code examples demonstrate how to set ACL policies using both Node.js and Python, with clear instructions for setting up variables like project ID, location, and user details.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Document AI Warehouse requires setting up Application Default Credentials, which is referenced with a link to more information.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples demonstrate the differences in setting ACLs for a specific document versus setting ACLs at the project level, indicating a conditional approach based on whether a document ID is specified.\u003c/p\u003e\n"]]],[],null,["# Set access control list (ACL)\n\nSet the access control list (ACL) for a document or a project.\n\nCode sample\n-----------\n\n### Node.js\n\n\nFor more information, see the\n[Document AI Warehouse Node.js API\nreference documentation](/nodejs/docs/reference/contentwarehouse/latest).\n\n\nTo authenticate to Document AI Warehouse, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n /**\n * TODO(developer): Uncomment these variables before running the sample.\n * project_id = 'YOUR_PROJECT_ID'\n * location = 'YOUR_PROJECT_LOCATION' // Format is 'us' or 'eu'\n * policyRole = 'YOUR_REQUESTED_ROLE',\n * policyMember = 'YOUR_REQUESTED_MEMBER',\n * user_id = 'user:YOUR_SERVICE_ACCOUNT_ID' # Format is \"user:xxxx@example.com\"\n * document_id = 'YOUR_DOCUMENT_ID'\n */\n\n //Import service client from google cloud\n const {DocumentServiceClient} = require('https://cloud.google.com/nodejs/docs/reference/contentwarehouse/latest/overview.html').v1;\n\n const apiEndpoint =\n location === 'us'\n ? 'contentwarehouse.googleapis.com'\n : `${location}-contentwarehouse.googleapis.com`;\n\n // Create client\n const serviceClient = new https://cloud.google.com/nodejs/docs/reference/contentwarehouse/latest/overview.html({apiEndpoint: apiEndpoint});\n\n // Set access control policies on project or document level.\n async function setACL() {\n //Initialize request argument(s)\n const request = {};\n request.policy = {\n bindings: [\n {\n role: policyRole,\n members: [policyMember],\n },\n ],\n };\n if (documentId !== 'YOUR_DOCUMENT_ID') {\n // Full document resource name, e.g.:\n // projects/{project_id}/locations/{location}/documents/{document_id}\n request.resource = `projects/${projectId}/locations/${location}/documents/${documentId}`;\n request.requestMetadata = {userInfo: {id: userId}};\n } else {\n // Full document resource name, e.g.: projects/{project_id}\n request.resource = `projects/${projectId}`;\n request.projectOwner = true;\n }\n\n // Make Request\n const response = serviceClient.setAcl(request);\n\n // Print Response\n response.then(\n result =\u003e console.log(`Success! Response: \\n${JSON.stringify(result)}`),\n error =\u003e console.log(`Failed! Response: \\n${error}`)\n );\n }\n\n### Python\n\n\nFor more information, see the\n[Document AI Warehouse Python API\nreference documentation](/python/docs/reference/contentwarehouse/latest).\n\n\nTo authenticate to Document AI Warehouse, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n from __future__ import annotations\n\n from typing import Any\n\n from google.cloud import contentwarehouse\n\n # TODO(developer): Uncomment these variables before running the sample.\n # project_number = 'YOUR_PROJECT_NUMBER'\n # location = 'YOUR_PROJECT_LOCATION' # Format is 'us' or 'eu'\n # document_id = 'YOUR_DOCUMENT_ID'\n # user_id = 'user:YOUR_SERVICE_ACCOUNT_ID' # Format is \"user:xxxx@example.com\"\n # policy = \"Policy in JSON format\"\n\n\n def set_acl(\n project_number: str,\n location: str,\n policy: dict[str, list[dict[str, Any]]],\n user_id: str,\n document_id: str = \"\",\n ) -\u003e None:\n \"\"\"Sets access control policies on project or document level.\n\n Args:\n project_number: Google Cloud project number.\n location: Google Cloud project location.\n policy: ACL policy to set, in JSON format.\n user_id: user:YOUR_SERVICE_ACCOUNT_ID.\n document_id: Record id in Document AI Warehouse.\n \"\"\"\n # Create a client\n client = contentwarehouse.https://cloud.google.com/python/docs/reference/contentwarehouse/latest/google.cloud.contentwarehouse_v1.services.document_service.DocumentServiceClient.html()\n\n # Initialize request argument(s)\n # Set document acl if document id is specified\n # else set acl on project level\n if document_id:\n request = contentwarehouse.https://cloud.google.com/python/docs/reference/contentwarehouse/latest/google.cloud.contentwarehouse_v1.types.SetAclRequest.html(\n # The full resource name of the document, e.g.:\n # projects/{project_number}/locations/{location}/documents/{document_id}\n resource=client.https://cloud.google.com/python/docs/reference/contentwarehouse/latest/google.cloud.contentwarehouse_v1.services.document_service.DocumentServiceClient.html#google_cloud_contentwarehouse_v1_services_document_service_DocumentServiceClient_document_path(project_number, location, document_id),\n request_metadata=contentwarehouse.https://cloud.google.com/python/docs/reference/contentwarehouse/latest/google.cloud.contentwarehouse_v1.types.RequestMetadata.html(\n user_info=contentwarehouse.https://cloud.google.com/python/docs/reference/contentwarehouse/latest/google.cloud.contentwarehouse_v1.types.UserInfo.html(id=user_id)\n ),\n )\n else:\n request = contentwarehouse.https://cloud.google.com/python/docs/reference/contentwarehouse/latest/google.cloud.contentwarehouse_v1.types.SetAclRequest.html(\n # The full resource name of the project, e.g.:\n # projects/{project_number}\n resource=client.https://cloud.google.com/python/docs/reference/contentwarehouse/latest/google.cloud.contentwarehouse_v1.services.document_service.DocumentServiceClient.html#google_cloud_contentwarehouse_v1_services_document_service_DocumentServiceClient_common_project_path(project_number),\n project_owner=True,\n )\n\n request.policy = policy\n\n # Make the request\n response = client.https://cloud.google.com/python/docs/reference/contentwarehouse/latest/google.cloud.contentwarehouse_v1.services.document_service.DocumentServiceClient.html#google_cloud_contentwarehouse_v1_services_document_service_DocumentServiceClient_set_acl(request=request)\n\n # Print response\n print(response)\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=contentwarehouse)."]]