Panduan ini menyediakan semua langkah penyiapan yang diperlukan untuk mulai menggunakan Enterprise Knowledge Graph.
Tentang konsol Google Cloud
Google Cloud console adalah UI web yang digunakan untuk menyediakan, mengonfigurasi, mengelola, dan memantau sistem yang menggunakan produk Google Cloud . Anda dapat menggunakan konsol Google Cloud untuk menyiapkan dan mengelola resource Enterprise Knowledge Graph.
Membuat project
Untuk menggunakan layanan yang disediakan oleh Google Cloud, Anda harus membuat project.
Project akan mengorganisasikan semua resource Google Cloud Anda. Project terdiri dari komponen berikut:
- Sekumpulan kolaborator
- API yang diaktifkan (dan resource lainnya)
- Alat pemantauan
- Informasi penagihan
- Autentikasi dan kontrol akses
Anda dapat membuat satu project, atau membuat beberapa project. Anda dapat menggunakan project untuk mengatur resource Google Cloud dalam hierarki resource. Untuk mengetahui informasi selengkapnya tentang project, lihat dokumentasi Resource Manager.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
Mengaktifkan API
Anda harus mengaktifkan Enterprise Knowledge Graph API untuk project Anda. Untuk mengetahui informasi selengkapnya tentang cara mengaktifkan API, lihat dokumentasi Service Usage.
Enable the Enterprise Knowledge Graph API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM
role (roles/serviceusage.serviceUsageAdmin), which
contains the serviceusage.services.enable permission. Learn how to grant
roles.
Menyiapkan autentikasi
Setiap aplikasi klien yang menggunakan API harus diautentikasi dan diberi akses ke resource yang diminta. Bagian ini menjelaskan konsep autentikasi penting dan memberikan langkah-langkah untuk menyiapkannya. Untuk mengetahui informasi selengkapnya, lihat Ringkasan autentikasi.
Tentang akun layanan
Ada beberapa opsi untuk autentikasi, tetapi sebaiknya Anda menggunakan akun layanan untuk autentikasi dan kontrol akses. Akun layanan memberikan kredensial untuk aplikasi, bukan untuk pengguna akhir. Project memiliki akun layanannya sendiri. Anda dapat membuat banyak akun layanan untuk sebuah project. Untuk mengetahui informasi selengkapnya, lihat Akun layanan.
Tentang peran
Saat memanggil API, Google Cloud memerlukan identitas yang memanggil (orang, entitas, atau proses yang berlaku dan atribut yang ditentukan) untuk memiliki izin yang sesuai. Anda dapat memberikan izin dengan memberikan peran ke akun layanan. Untuk mengetahui informasi selengkapnya, lihat dokumentasi Identity and Access Management (IAM).
Untuk mencoba Enterprise Knowledge Graph API, Anda dapat menggunakan peran Project > Owner dalam langkah-langkah berikut. Peran Project > Owner memberikan izin penuh ke akun layanan untuk mengakses resource di project Anda. Jika akun layanan Anda tidak memerlukan izin penuh, Anda dapat menentukan peran yang lebih ketat menggunakan konsolGoogle Cloud . Untuk mengetahui daftar izin dan peran untuk Enterprise Knowledge Graph, lihat Izin Enterprise Knowledge Graph dan Peran Enterprise Knowledge Graph. Untuk mengetahui informasi tentang cara mengelola izin menggunakan peran IAM, lihat memberikan peran ke akun layanan.
Tentang kunci akun layanan
Akun layanan dikaitkan dengan satu atau beberapa pasangan kunci publik atau pribadi. Saat membuat pasangan kunci baru, Anda mendownload kunci pribadi. Google Cloud CLI menggunakan kunci pribadi Anda untuk membuat kredensial saat memanggil API.
Buat akun layanan dan download file kunci pribadi
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
Menggunakan file kunci akun layanan di lingkungan Anda
Provide authentication credentials to your application code by setting the
environment variable GOOGLE_APPLICATION_CREDENTIALS. This
variable applies only to your current shell session. If you want the variable
to apply to future shell sessions, set the variable in your shell startup file,
for example in the ~/.bashrc or ~/.profile file.
Linux atau macOS
export GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH"Replace KEY_PATH with the path of the JSON file that contains your credentials.
For example:
export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json"
Windows
For PowerShell:
$env:GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH"Replace KEY_PATH with the path of the JSON file that contains your credentials.
For example:
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\username\Downloads\service-account-file.json"
For command prompt:
set GOOGLE_APPLICATION_CREDENTIALS=KEY_PATHReplace KEY_PATH with the path of the JSON file that contains your credentials.