您可以使用API在GoodData中创建新项目:http://docs.gooddata.apiary.io/#project
有时,即从模板创建项目时,项目创建并不是同步的。当我在项目准备就绪之前使用它时,我会收到像403和409这样的错误。
项目有哪些可能的状态(除了ENABLED)?创建项目的推荐方法是什么(可能是针对某个州进行轮询)?什么是错误状态以及如何处理它们?代码示例很有用。
答案 0 :(得分:2)
是的,最好的方法是轮询项目状态。
项目可以有这些状态。
'制备' | ' PREPARED' | ' LOADING' | ' ENABLED' | ' DISABLED' | ' DELETED' | ' ARCHIVED',
我可以为您创建示例,您的首选语言是什么?
Jiri SimonGoodData支持
答案 1 :(得分:2)
我建议您使用ruby Cookbook创建新项目。 Gooddata在ruby中有非常好的库来处理项目
使用模板创建项目 http://sdk.gooddata.com/gooddata-ruby-examples/#_creating_project_from_template
创建一个空项目 http://sdk.gooddata.com/gooddata-ruby-examples/#_creating_empty_project
理想情况下,您希望使用云连接etl工具创建一个好数据项目,如以下链接中所述 https://help.gooddata.com/cloudconnect/manual/gooddata-project.html
答案 2 :(得分: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"