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.
Get access control list (ACL)
Stay organized with collections
Save and categorize content based on your preferences.
Get 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 code samples in Node.js and Python for retrieving the Access Control List (ACL) of either a specific document or an entire project within Document AI Warehouse.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples demonstrate how to set up authentication using Application Default Credentials for accessing Document AI Warehouse.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code utilizes the DocumentServiceClient in Node.js and Python to interact with the Document AI Warehouse API and fetch the ACL.\u003c/p\u003e\n"],["\u003cp\u003eThe examples showcase how to specify a resource (either a document or a project) and user information in the request to fetch the corresponding ACL.\u003c/p\u003e\n"],["\u003cp\u003eThe instructions on how to navigate and look for other Google Cloud product code samples using the Google Cloud Sample Browser is detailed.\u003c/p\u003e\n"]]],[],null,["# Get access control list (ACL)\n\nGet 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 /**\n * TODO(developer): Uncomment these variables before running the sample.\n * const projectId = 'YOUR_PROJECT_ID';\n * const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu'\n * const documentId = 'YOUR_DOCUMENT_ID',\n * const userId = \"user:xxxx@example.com\" // Format is \"user:xxxx@example.com\"\n */\n\n // Import 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 service client\n const serviceClient = new https://cloud.google.com/nodejs/docs/reference/contentwarehouse/latest/overview.html({apiEndpoint: apiEndpoint});\n\n // Fetches access control policies on project or document level.\n async function fetchACL() {\n // Initialize request argument(s)\n const request = {};\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.fetchAcl(request);\n\n // Print out 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 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\n\n def fetch_acl(\n project_number: str, location: str, user_id: str, document_id: str = \"\"\n ) -\u003e None:\n \"\"\"Fetches 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 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 # Fetch document acl if document id is specified\n # else fetch 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.FetchAclRequest.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.FetchAclRequest.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 # Make 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_fetch_acl(request)\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)."]]