이 문서에서는 주 구성원에게 Data Catalog tagTemplateUser 역할을 부여하는 방법을 설명합니다. 리소스 프로젝트에서 Data Catalog 태그 템플릿을 만든 후에는 이 작업을 할 수 있습니다. 이를 통해 메타데이터를 만들 수 있습니다. 즉, 템플릿을 사용하여 데이터 리소스에 태그를 지정할 수 있습니다. 자세한 내용은 Google Cloud 리소스에 태그 연결을 참고하세요.
다음 섹션에서는 tagTemplateUser 역할을 부여하는 방법을 보여줍니다.
tagTemplateUser 역할 부여
콘솔
콘솔
프로젝트의 주 구성원에 Data Catalog tagTemplateUser 역할을 부여하려면 다음 안내를 따르세요.
Google Cloud 콘솔에서 IAM으로 이동하고 주 구성원 목록 오른쪽에 있는 수정(edit) 버튼을 클릭합니다.
권한 수정 대화상자에서 add다른 역할 추가를 클릭한 다음 역할 선택 드롭다운 목록을 클릭합니다.
filter_list필터 상자에서 Data Catalog TagTemplate User를 삽입하여 이 역할을 표시한 다음 선택하고 저장을 클릭합니다.
Data Catalog에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
importcom.google.cloud.datacatalog.v1.DataCatalogClient;importcom.google.cloud.datacatalog.v1.TagTemplateName;importcom.google.iam.v1.Binding;importcom.google.iam.v1.Policy;importcom.google.iam.v1.SetIamPolicyRequest;importjava.io.IOException;// Sample to grant tag access on templatepublicclassGrantTagTemplateUserRole{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.StringprojectId="my-project";StringtagTemplateId="my_tag_template";grantTagTemplateUserRole(projectId,tagTemplateId);}publicstaticvoidgrantTagTemplateUserRole(StringprojectId,StringtemplateId)throwsIOException{// Currently, Data Catalog stores metadata in the us-central1 region.Stringlocation="us-central1";// Format the Template name.StringtemplateName=TagTemplateName.newBuilder().setProject(projectId).setLocation(location).setTagTemplate(templateId).build().toString();// Initialize client that will be used to send requests. This client only needs to be created// once, and can be reused for multiple requests. After completing all of your requests, call// the "close" method on the client to safely clean up any remaining background resources.try(DataCatalogClientdataCatalogClient=DataCatalogClient.create()){// Create a Binding to add the Tag Template User role and member to the policy.Bindingbinding=Binding.newBuilder().setRole("roles/datacatalog.tagTemplateUser").addMembers("group:example-analyst-group@google.com").build();// Create a Policy object to update Template's IAM policy by adding the new binding.PolicypolicyUpdate=Policy.newBuilder().addBindings(binding).build();SetIamPolicyRequestrequest=SetIamPolicyRequest.newBuilder().setPolicy(policyUpdate).setResource(templateName).build();// Update Template's policy.dataCatalogClient.setIamPolicy(request);System.out.println("Role successfully granted");}}}
Data Catalog에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
// Import the Google Cloud client library.const{DataCatalogClient}=require('@google-cloud/datacatalog').v1;constdatacatalog=newDataCatalogClient();asyncfunctiongrantTagTemplateUserRole(){// Grant the tagTemplateUser role to a member of the project./** * TODO(developer): Uncomment the following lines before running the sample. */// const projectId = 'my_project'; // Google Cloud Platform project// const templateId = 'my_existing_template';// const memberId = 'my_member_id'constlocation='us-central1';// Format the Template name.consttemplateName=datacatalog.tagTemplatePath(projectId,location,templateId);// Retrieve Template's current IAM Policy.const[getPolicyResponse]=awaitdatacatalog.getIamPolicy({resource:templateName,});constpolicy=getPolicyResponse;// Add Tag Template User role and member to the policy.policy.bindings.push({role:'roles/datacatalog.tagTemplateUser',members:[memberId],});constrequest={resource:templateName,policy:policy,};// Update Template's policy.const[updatePolicyResponse]=awaitdatacatalog.setIamPolicy(request);updatePolicyResponse.bindings.forEach(binding=>{console.log(`Role: ${binding.role}, Members: ${binding.members}`);});}grantTagTemplateUserRole();
Data Catalog에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
fromgoogle.cloudimportdatacatalog_v1fromgoogle.iam.v1importiam_policy_pb2asiam_policyfromgoogle.iam.v1importpolicy_pb2datacatalog=datacatalog_v1.DataCatalogClient()# TODO: Set these values before running the sample.project_id="project_id"tag_template_id="existing_tag_template_id"# For a full list of values a member can have, see:# https://cloud.google.com/iam/docs/reference/rest/v1/Policy?hl=en#bindingmember_id="user:super-cool.test-user@gmail.com"# For all regions available, see:# https://cloud.google.com/data-catalog/docs/concepts/regionslocation="us-central1"# Format the Template name.template_name=datacatalog_v1.DataCatalogClient.tag_template_path(project_id,location,tag_template_id)# Retrieve Template's current IAM Policy.policy=datacatalog.get_iam_policy(resource=template_name)# Add Tag Template User role and member to the policy.binding=policy_pb2.Binding()binding.role="roles/datacatalog.tagTemplateUser"binding.members.append(member_id)policy.bindings.append(binding)set_policy_request=iam_policy.SetIamPolicyRequest(resource=template_name,policy=policy)# Update Template's policy.policy=datacatalog.set_iam_policy(set_policy_request)forbindinginpolicy.bindings:formemberinbinding.members:print(f"Member: {member}, Role: {binding.role}")
REST 및 명령줄
REST
해당 언어의 Cloud 클라이언트 라이브러리에 액세스할 수 없거나 REST 요청을 사용하여 API를 테스트하려는 경우 다음 예시를 참조하고 Data Catalog REST API 문서를 참조하세요.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
project-id: Google Cloud 프로젝트 ID
template-id: 태그 템플릿 ID
HTTP 메서드 및 URL:
POST https://datacatalog.googleapis.com/v1/projects/project-id/locations/region/tagTemplates/template-id:setIamPolicy
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-01-16(UTC)"],[[["\u003cp\u003eThis document provides instructions on how to grant the Data Catalog \u003ccode\u003etagTemplateUser\u003c/code\u003e role to principals, enabling them to use a tag template to tag data resources with metadata.\u003c/p\u003e\n"],["\u003cp\u003eGranting the \u003ccode\u003etagTemplateUser\u003c/code\u003e role can be achieved through the Google Cloud console by adding the role to a principal's permissions.\u003c/p\u003e\n"],["\u003cp\u003ePrincipals may require additional roles to write metadata to resources they don't own, beyond just the \u003ccode\u003etagTemplateUser\u003c/code\u003e role, such as roles for writing to BigQuery and Pub/Sub.\u003c/p\u003e\n"],["\u003cp\u003eCode samples are given for Java, Node.js, and Python to allow for programmatic assignment of this role, as well as REST API and CLI examples.\u003c/p\u003e\n"],["\u003cp\u003eThe necessary authentication to the Data Catalog for programmatic assignment of this role requires the use of the Application Default Credentials.\u003c/p\u003e\n"]]],[],null,[]]