🛠️ Usage 方法
Port 支持各种集成、应用程序和工具,可让您对软件目录进行建模、摄取数据和调用操作,其中一些核心设置方法如下:
- Port 的 API;
- Port 的 Terraform Provider;
- Port 的网络用户界面。
请参阅下面的章节,了解如何使用不同的方法来定义您的蓝图和关系:
要使用 Port 的 API 和 Terraform Provider,您需要 API 凭据。
To get your Port API credentials go to your Port application, click on the ... button in the top right corner, and select Credentials. Here you can view and copy your CLIENT_ID and CLIENT_SECRET:
- API
- Terraform
- UI
Port 的API 提供了一个方便的 REST 接口,用于在软件目录中执行 CRUD 操作。
Port 的 API 基本 URL 为: https://api.getport.io/v1。
应用程序接口支持所有常见的 HTTP 方法: "GET"、"POST"、"PUT"、"PATCH"、"DELETE"。
例如,所有应用程序接口端点都遵循基于资源的访问模式:
- 基于蓝图的路由以https://api.getport.io/v1/blueprints`;
- 基于实体的路由以https://api.getport.io/v1/blueprints/{blueprint_identifier}/entities`(因为它们是与蓝图绑定的资源);
- 基于自助操作的路由从以下地址开始: https://api.getport.io/v1/blueprints/{blueprint_identifier}/actions`;
- 基于记分卡的路由从:
https://api.getport.io/v1/blueprints/{blueprint_identifier}/scorecards开始; - 等等。
要进一步了解不同 API 对象的 JSON 结构,请参阅各自的类别和结构参考资料,例如: blueprint structure 。
Check out Port's API reference to learn more.
Port'sTerraform provider 允许您使用 Infrastructure-as-Code (IaC) 配置软件目录。
To install and use Port's Terraform provider, you will need to install the Terraform CLI
To install the Terraform provider, create a .tf file specifying the provider and the required Port credentials:
terraform {
required_providers {
port = {
source = "port-labs/port-labs"
version = "~> 1.0.0"
}
}
}
provider "port" {
client_id = "{YOUR CLIENT ID}" # or set the environment variable PORT_CLIENT_ID
secret = "{YOUR CLIENT SECRET}" # or set the environment variable PORT_CLIENT_SECRET
}
Then run the following command to install the provider in your Terraform workspace:
terraform init
要使用 Port 的 Terraform Provider 创建蓝图,您需要一个定义port_blueprint 资源的.tf文件:
resource "port_blueprint" "myBlueprint" {
title = "My blueprint"
icon = "My icon"
identifier = "myIdentifier"
description = "My description"
}
然后运行 "terraform plan "查看将要创建的新蓝图,再运行 "terraform apply "在 Port 的软件目录内创建您定义的蓝图。
要了解有关不同 API 对象的 Terraform 资源定义的更多信息,请参阅各自的类别和结构参考资料,例如configure blueprints in Port 和Terraform provider 。
要使用用户界面配置软件目录,请访问DevPortal Builder 页面,然后按照 "添加蓝图 "用户界面、"测试数据 "模态和其他可视化工具帮助您配置 Port。