所需的角色
如需获得删除代码库所需的权限,请让您的管理员为您授予以下 IAM 角色:
-
Secure Source Manager Instance Accessor (
roles/securesourcemanager.instanceAccessor) 在 Secure Source Manager 实例上 -
针对代码库的 Secure Source Manager Repo Admin (
roles/securesourcemanager.repoAdmin)
如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
如需了解如何授予 Secure Source Manager 角色,请参阅使用 IAM 进行访问权限控制和向用户授予实例访问权限。
删除代码库
您可以使用 gcloud、网页界面或 API 删除代码库。
网页界面
-
如需通过网页界面访问 Secure Source Manager 实例,请将以下网址复制到浏览器地址栏中。
INSTANCE_ID-PROJECT_NUMBER.LOCATION.sourcemanager.dev请替换以下内容:
- 将 INSTANCE_ID 替换为实例名称。
- 将 PROJECT_NUMBER 替换为实例的 Google Cloud项目编号。如需了解如何标识项目,请参阅标识项目。
- 将 LOCATION 替换为实例的区域。
- 在代码库列表中,选择要删除的代码库。
- 点击设置。
- 在代码库设置中,点击删除此代码库。
gcloud
如需删除代码库,请运行以下命令:
gcloud source-manager repos delete REPOSITORY_ID --region=REGION --project=PROJECT_ID
替换以下内容:
REPOSITORY_ID:要删除的代码库的 ID。REGION:Secure Source Manager 实例所在的区域(例如us-central1)。PROJECT_ID:Secure Source Manager 实例所在的项目 ID。
API
如需删除代码库和所有关联数据,请使用以下 HTTP 方法和网址。
在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:运行 Secure Source Manager 的 Google Cloud 项目的项目 ID。
- LOCATION:实例所在的区域。如需了解支持的位置,请参阅位置。
- REPOSITORY_ID:代码库 ID。
HTTP 方法和网址:
DELETE https://securesourcemanager.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/repositories/REPOSITORY_ID
如需发送您的请求,请展开以下选项之一:
您应该收到类似以下内容的 JSON 响应:
"name":"operations/cc3ea26c-9b57-11ed-be0a-2e3b5910efef","metadata":{"@type":"type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata","createTime":"2023-01-23T19:54:49.904779921Z","endTime":"2023-01-23T19:54:50.947030402Z","target":"projects/my-project/locations/us-central1/repositories/my-repo","verb":"delete","apiVersion":"v1"},"done":true,"response":{"@type":"type.googleapis.com/google.protobuf.Empty"}
```