GCP 人工智能平台 API

GCP AI platform API

我正在尝试以编程方式在 GCP 中创建“AI Platform Notebooks”。 gcloud sdk 确实支持管理这些笔记本,但不支持创建它们。并且没有支持 Node.js(我正在使用的语言)的客户端库。然而,GCP REST API 支持创建笔记本,如文档 here 所述。但是,我正在努力弄清楚如何在请求的 JSON 中指定我想要的笔记本。从 GCP 网站 UI,我想要的设置是:

但我正在努力将其转化为对 REST API 的 JSON 请求。以下是我到目前为止所拥有的。我不确定其中的任何一个是否正确,而且我肯定缺少环境(tensorflow 2.1)和仅限单用户访问。除了随机尝试不同的请求直到它起作用之外,我不知道如何实现这一目标。 (我暂时保留了一些 JSON 只是根据文档指定类型,以供参考)。

POST https://notebooks.googleapis.com/v1beta1/projects/my-project/locations/europe-west2/instances
{
  "name" : "testing-instance",
  "instanceOwners": [
    string
  ],
  "serviceAccount": "team@project.iam.gserviceaccount.com",
  "machineType": "e2-highmem-2 (Efficient Instance, 2 vCPUs, 16 GB RAM)",
  "acceleratorConfig": {
    object (AcceleratorConfig)
  },
  "state": enum (State),
  "installGpuDriver": boolean,
  "customGpuDriverPath": string,
  "bootDiskType": enum (DiskType),
  "bootDiskSizeGb": string,
  "dataDiskType": enum (DiskType),
  "dataDiskSizeGb": string,
  "noRemoveDataDisk": boolean,
  "diskEncryption": enum (DiskEncryption),
  "kmsKey": string,
  "noPublicIp": boolean,
  "noProxyAccess": boolean,
  "network": string,
  "subnet": string,
  "labels": {
    string: string,
    ...
  },
  "metadata": {
    string: string,
    ...
  },
  "createTime": string,
  "updateTime": string,

  // Union field environment can be only one of the following:
  "vmImage": {
    object (VmImage)
  },
  "containerImage": {
    object (ContainerImage)
  }
  // End of list of possible types for union field environment.
}

这里需要JSON

{
  "name": "testing-instance",
  "machineType": "zones/europe-west2-a/machineTypes/e2-highmem-2",
  "guestAccelerators": [],
  "metadata": {
    "items": [
      {
        "key": "proxy-mode",
        "value": "mail"
      },
      {
        "key": "framework",
        "value": "TensorFlow:2.1"
      },
      {
        "key": "proxy-user-mail",
        "value": "firstname.surname@email.com"
      }
    ]
  },
  "disks": [
    {
      "boot": true,
      "autoDelete": true,
      "initializeParams": {
        "diskType": "zones/europe-west2-a/diskTypes/pd-standard",
        "diskSizeGb": "100",
        "sourceImage": "projects/deeplearning-platform-release/global/images/family/tf2-2-1-cu101-notebooks-debian-9"
      }
    }
  ],
  "scheduling": {
    "onHostMaintenance": "MIGRATE"
  },
  "networkInterfaces": [
    {
      "subnetwork": "https://www.googleapis.com/compute/v1/projects/gbl-imt-homerider-basguillaueb/regions/europe-west2/subnetworks/datalab-network",
      "accessConfigs": [
        {
          "name": "external-nat",
          "type": "ONE_TO_ONE_NAT"
        }
      ]
    }
  ],
  "serviceAccounts": [
    {
      "email": "team@project.iam.gserviceaccount.com",
      "scopes": [
        "https://www.googleapis.com/auth/cloud-platform",
        "https://www.googleapis.com/auth/userinfo.email"
      ]
    }
  ],
  "tags": {
    "items": [
      "deeplearning-vm"
    ]
  }
}

你自己猜不出来。我怎样做?使用控制台执行此操作,在提交之前,打开 Chorme 调试器并捕获网络请求。 post 请求包含此 JSON!

尽情享受