2

您可以使用 API 在 GoodData 中创建一个新项目:http ://docs.gooddata.apiary.io/#project

有时,即从模板创建项目时,项目创建不是同步的。当我在项目准备好之前使用它时,我会收到 403 和 409 之类的错误。

项目的可能状态是什么(除了启用)?创建项目的推荐方法是什么(可能是针对某个状态进行轮询)?什么是错误状态以及如何处理它们?代码示例会很有用。

4

3 回答 3

2

是的,最好的方法是轮询项目状态。

项目可以有这些状态。

'准备' | '准备' | '加载' | '启用' | '禁用' | '删除' | '存档',

我可以为您创建示例,您的首选语言是什么?

吉里·西蒙

好数据支持

于 2014-03-26T07:40:54.747 回答
2

我建议您使用 ruby​​ 食谱来创建新项目。Gooddata 在 ruby​​ 中有非常好的库来处理项目

使用模板创建项目 http://sdk.gooddata.com/gooddata-ruby-examples/#_creating_project_from_template

创建一个空项目 http://sdk.gooddata.com/gooddata-ruby-examples/#_creating_empty_project

理想情况下,您可能希望使用以下链接 https://help.gooddata.com/cloudconnect/manual/gooddata-project.html中提到的 cloud connect etl 工具创建一个 gooddata 项目

于 2018-07-17T12:59:03.960 回答
1

在这里,您可以在 python 中看到非常简单的示例。

from urllib2 import Request, urlopen
import Cookie
from json import dumps
import re
import ast



values = dumps({"postUserLogin":{"login":"jiri.simon@gooddata.com","password":"mypassword","remember":1}})
headers = {"Accept": "application/json", "Content-Type": "application/json"}
request = Request("https://na1.secure.gooddata.com/gdc/account/login", data=values, headers=headers)
response_body = urlopen(request)
#print response_body.read()
msg = response_body.info()
#print msg.getheaders('set-cookie')
x=msg.getheaders('set-cookie')
import re
GD_SST = re.search('GDCAuthSST(.*?);', x[1]).group()
print GD_SST


headers = {"Cookie": "$Version=0; $Path=/gdc/account", "Accept": "application/json", "Content-Type": "application/json"}
headers['Cookie'] = GD_SST
request = Request("https://na1.secure.gooddata.com/gdc/account/token", headers=headers)
response_body = urlopen(request)
#print response_body.read() 
#print response_body.info() 
msg = response_body.info()
#print msg.getheaders('set-cookie')
x=msg.getheaders('set-cookie')
#print x
GD_TT = re.search('GDCAuthTT(.*?);', x[0]).group()
print GD_TT


values = dumps({ "project" : {
       "content" : {"guidedNavigation": 1, "driver" : "Pg", "authorizationToken" : "MYTOKEN"},
       "meta" : {
       "title" : "Test Project API",
       "summary" : "Testing Project",
       "projectTemplate" : "/projectTemplates/{templateName}/{version}"
       } }
})
headers = {"Accept": "application/json", "Content-Type": "application/json"}
headers['Cookie'] = GD_TT
request = Request("https://na1.secure.gooddata.com/gdc/projects", data=values, headers=headers)
response_body = urlopen(request).read()
#project_url=response_body['uri']
project_url=ast.literal_eval(response_body)['uri']
print project_url

request = Request("https://na1.secure.gooddata.com%s" % project_url , headers=headers)
#response_body = urlopen(request).read()
#print response_body
response_body = urlopen(request).read()
print response_body
#project_details = ast.literal_eval(response_body)['project']
#project_state = project_details['content']['state']

project_state = " "
#print "project_state is %s" % project_state
while project_state != "ENABLED" or project_state != "DELETED" :

    response_body = urlopen(request).read()
    #print response_body
    project_details = ast.literal_eval(response_body)['project']
    project_state = project_details['content']['state']
    print "project_state is %s" % project_state
    if project_state == "DELETED":
      break

if project_state == "ENABLED" :
  print "project created %s" %project_ur
else:
 print "something was wrong"
于 2014-03-26T13:24:13.123 回答