如何使用API将项目添加到Google开发人员控制台


How to add project to the Google Developer Console with the API?

我在Google开发者控制台中有几个项目启用了Google Cloud DNS API。

这就是我想做的:

  1. 使用API添加项目
  2. 获取项目名称
  3. 添加区域
  4. 获取区域名称

我已经使用Google Cloud API完成了编辑/删除/添加操作。

我对此采取了错误的方法。

我通过将域名/区域名称添加到已经存在的项目中来完成这项工作。谢谢你谷歌。

def add_zone(self, domain=None, zone_name=None, project_name='stable-plasma-833'):
    BODY = {
          'name' : zone_name,
          'dnsName' : domain+".",
          'description' : domain+ ' zone'
    }
    try:
        response = self.service.managedZones().create(project=project_name,
                                                   body=BODY
                                                   ).execute()
        print response
    except errors.HttpError, error:
        print 'An error occurred: %s' % error