Skip to content
Eugene edited this page Apr 26, 2022 · 20 revisions

Initialisation

Configure connection using one of constructors of GoodData class. One can then get initialised service he needs from the newly constructed instance. This instance can be also used later for logout from GoodData Platform.

GoodDatagd = newGoodData("roman@gooddata.com", "Roman1");

If you need to tune additional settings like maxConnections, connectionTimeout, connectionTimeout or socketTimeout, use GoodDataSettings class and passed its instance to GoodData constructor.

Project API

Manage GoodData projects with its users, user roles, templates, validation and feature flags.

ProjectServiceprojectService = gd.getProjectService();

Get all projects current user has access to.

Collection<Project> projects = projectService.getProjects();

Create new project.

Projectproject = projectService.createProject(newProject("my project", "MyToken")).get();

Remove project.

projectService.removeProject(project);

Validate project.

Set<ProjectValidationType> types = projectService.getAvailableProjectValidationTypes(project);
ProjectValidationResultsresults = projectService.validateProject(project, types).get();

List project users.

List<User> users = newArrayList<>();
List<User> page;
while (!(page = projectService.listUsers(project, newPageRequest(users.size(), 100))).isEmpty()) {
users.addAll(page);
}

List project user roles.

Set<Role> roles = projectService.getRoles(project);

List project templates.

Collection<ProjectTemplate> templates = projectService.getProjectTemplates(project);

Send invitation

Invitationinvitation = newInvitation("user@example.com");
CreatedInvitationsinvitations = projectService.sendInvitations(project, invitation); 

Add user to project

Useruser = projectService.addUserToProject(project, account, role1, role2);

Update user in project

projectService.updateUserInProject(project, user)

Account API

Create account in GoodData

AccountnewAccount = newAccount("MyMail@gooddata.com", "Password", "FistName", "LastName");
Accountaccount = accountService.createAccount(newAccount, "MyOrganizationName");

Remove account

accountService.removeAccount(account);

Create and remove account can be executed only by domain admin.

Project Model API

Create and update the project model, execute MAQL DDL,...

ModelServicemodelService = gd.getModelService();
ModelDiffdiff = modelService.getProjectModelDiff(project,
newInputStreamReader(getClass().getResourceAsStream("/person.json"))).get();
modelService.updateProjectModel(project, diff).get();
modelService.updateProjectModel(project, "MAQL DDL EXPRESSION").get();

Metadata API

Query, create and update project metadata - attributes, facts, metrics, reports,...

MetadataServicemd = gd.getMetadataService();
Stringfact = md.getObjUri(project, Fact.class, identifier("fact.person.shoesize"));
Metricm = md.createObj(project, newMetric("Avg shoe size", "SELECT AVG([" + fact + "])", "#,##0"));
Attributeattr = md.getObj(project, Attribute.class, identifier("attr.person.department"));
ReportDefinitiondefinition = GridReportDefinitionContent.create(
"Department avg shoe size",
asList("metricGroup"),
asList(newAttributeInGrid(attr.getDefaultDisplayForm().getUri())),
asList(newGridElement(m.getUri(), "Avg shoe size"))
);
definition = md.createObj(project, definition);
Reportreport = md.createObj(project, newReport(definition.getTitle(), definition));

Create and retrieve scheduled mails on reports and dashboards.

ScheduledMailscheduledMail = md.createObj(
project,
(newScheduledMail("Scheduled Mail Title", "Scheduled Mail Summary"))
.setRecurrency("0:0:0:1*12:0:0")
.setStartDate(newLocalDate(2012, 6, 5))
.setTimeZone("America/Los_Angeles")
.addToAddress("user_in_project@example.com")
.addBccAddress("another_user_in_project@example.com")
.setSubject("Mail subject")
.setBody("Mail body")
.addReportAttachment(reportDefinition,
Collections.singletonMap("pageOrientation", "landscape"),
pdf, xls)
);
Collection<Entry> result = md.find(project, ScheduledMail.class);
for (Entrye : result) {
ScheduledMailschedule = md.getObjByUri(e.getLink(), ScheduledMail.class);
}

Import/Export API

Import/export project metadata.

ImportExportServiceimportExportService = gd.getImportExportService();
PartialMdExportexportConfig = newPartialMdExport("/gdc/md/projectId/obj/123");
PartialMdExportTokenexportToken = importExportService.partialExport(projectFrom, exportConfig).get();
importExportService.partialImport(projectTo, exportToken).get();

Dataset API

DatasetServicedatasetService = gd.getDatasetService();

Upload data to dataset.

datasetService.loadDataset(project, "datasetId", newFileInputStream("data.csv")).get();

Upload data to datasets using batch upload.

DatasetManifestpersonManifest = datasetService.getDatasetManifest(project, "dataset.person");
personManifest.setSource(getClass().getResourceAsStream("/person.csv"));
DatasetManifestcityManifest = datasetService.getDatasetManifest(project, "dataset.city");
cityManifest.setSource(getClass().getResourceAsStream("/city.csv"));
datasetService.loadDatasets(project, personManifest, cityManifest).get();

Update data in dataset.

datasetService.updateProjectData(project, "DELETE FROM {attr.person.name} WHERE {label.person.name} = \"not exists\";");

List all uploads for a dataset.

Collection<Upload> personUploads = datasetService.listUploadsForDataset(project, "dataset.person");

Get last upload for a dataset.

UploadpersonLastUpload = datasetService.getLastUploadForDataset(project, "dataset.person");

Get project`s upload statistics (e.g. successful uploads count).

UploadStatisticsuploadStatistics = datasetService.getUploadStatistics(project);
intsuccessfulUploadsCount = uploadStatistics.getUploadsCount("OK");

Report API

Execute and export reports.

ReportServicereportService = gd.getReportService();
reportService.exportReport(definition, PNG, newFileOutputStream("report.png"));

Execute AFM API

Executes reports with new visualization structures like AFM or Visualization Object.

Execute AFM

Executes AFM object and gets execution response (polling object for execution result).

ExecuteAfmServiceservice = gd.getExecuteAfmService();
Afmafm = newAfm()
.addAttribute(newAttributeItem(displayForm, localIdentifier, "Some Attribute"))
.addMeasure(newMeasureItem(measureDefinition, "measure1"));
Executionexecution = newExecution(afm);
ExecutionResponseresponse = service.executeAfm(project, execution);

Execute Visualization Object

Executes reference to stored metadata of Visualization Object and gets execution response (polling object for execution result).

ExecuteAfmServiceservice = gd.getExecuteAfmService();
VisualizationExecutionexecution = newVisualizationExecution("/gdc/md/project123/obj/12");
ExecutionResponseresponse = service.executeVisualization(project, execution);

Fetch execution result

Fetches execution result data from AFM execution response.

ExecuteAfmServiceservice = gd.getExecuteAfmService();
ExecutionResultexecutionResult = service.getResult(executionResponse).get();

DataStore API

Manage files on the data store (currently backed by WebDAV) - user staging area.

DataStoreServicedataStoreService = gd.getDataStoreService();
dataStoreService.upload("/dir/file.txt", newFileInputStream("file.txt"));
InputStreamstream = dataStoreService.download("/dir/file.txt");
dataStoreService.delete("/dir/file.txt");

Warehouse API

Manage warehouses - create, update, list and delete.

WarehouseServicewarehouseService = gd.getWarehouseService();
Warehousewarehouse = warehouseService.createWarehouse(newWarehouse("title", "authToken", "description")).get();
Stringjdbc = warehouse.getJdbcConnectionString();
Collection<Warehouse> warehouseList = warehouseService.listWarehouses();
warehouseService.removeWarehouse(warehouse);

Manage warehouse schemas

WarehouseServicewarehouseService = gd.getWarehouseService();
Warehousewarehouse = warehouseService.getWarehouseById("someId");
WarehouseSchemaschema = warehouseService.getDefaultWarehouseSchema(warehouse);
Collection<WarehouseSchema> schemaList = warehouseService.listWarehouseSchemas(warehouse);

Manage S3 credentials for warehouses - create, get, update, delete and list.

WarehouseServicewarehouseService = gd.getWarehouseService();
Warehousewarehouse = warehouseService.getWarehouseById("someId");
WarehouseS3CredentialsnewS3Credentials = newWarehouseS3Credentials("region", "accessKey", "secretKey");
newS3Credentials = warehouseService.addS3Credentials(warehouse, s3Credentials).get();
WarehouseS3Credentialss3Credentials = warehouseService.getWarehouseS3Credentials(warehouse, "region", "accessKey");
s3Credentials.setSecretKey("newSecretKey");
s3Credentials = warehouseService.updateS3Credentials(s3Credentials).get();
warehouseService.removeS3Credentials(s3Credentials);
Collection<WarehouseS3Credentials> s3CredentialsList = warehouseService.listWarehouseS3Credentials(warehouse);

Dataload Process API

Manage dataload processes - create, update, list, delete, and process executions - execute, get logs, schedules,...

ProcessServiceprocessService = gd.getProcessService();
DataloadProcesscreate = newDataloadProcess("name", "GRAPH");
DataloadProcessprocess = processService.createProcess(project, create, newFile("path/to/processdatadir"));
ProcessExecutionexec = newProcessExecution(process, "myGraph.grf");
ProcessExecutionDetailexecutionDetail = processService.executeProcess(exec).get();
processService.getExecutionLog(executionDetail, newFileOutputStream("file/where/the/log/willbewritten"));
processService.createSchedule(project, newSchedule(process, "myGraph.grf", "0 0 * * *"));

Create, update process from appstore. These methods are asynchronous.

ProcessServiceprocessService = gd.getProcessService();
DataloadProcesscreatenewDataloadProcess("name", "RUBY" ,"appstorePath");
DataloadProcessprocess = processService.createProcessFromAppstore(project, create).get();
process.setPath("differentAppstorePath");
process = processService.updateProcessFromAppstore(project, process).get();

Support for DATALOAD processes is rather rudimentary, as they are not documented anywhere, to execute DATALOAD process use:

ProcessExecutionexec = newProcessExecution(process, null, singletonMap("GDC_DE_SYNCHRONIZE_ALL", "true"));
ProcessExecutionDetailexecutionDetail = processService.executeProcess(exec).get();

Hierarchical Config API

Manage hierarchical configuration.

HierarchicalConfigServicehierarchicalConfigService = gd.getHierarchicalConfigService();

Returns all config items for given project (including inherited ones from its hierarchy).

ConfigItemsconfigItems = hierarchicalConfigService.listProjectConfigItems(project);

Returns config item for given project (even if it's inherited from its hierarchy).

ConfigItemconfigItem = hierarchicalConfigService.getProjectConfigItem(project, configName);

Creates or updates config item for given project.

ConfigItemconfigItem = newConfigItem("name", "value");
ConfigItemcreated = hierarchicalConfigService.setProjectConfigItem(project, configItem);

Removes existing project config item.

hierarchicalConfigService.removeProjectConfigItem(configItem);

Feature Flag API

!!!DEPRECATED!!! Use Hierarchical Configuration API

Manage feature flags.

FeatureFlagServicefeatureFlagService = gd.getFeatureFlagService();

Lists aggregated feature flags for given project and current user (aggregates global, project group, project and user feature flags).

FeatureFlagsflags = featureFlagService.listFeatureFlags(project);

List project's feature flags (only project scoped flags).

ProjectFeatureFlagsflags = featureFlagService.listProjectFeatureFlags(project);

Get project's feature flag (only project scoped flags) by unique name (aka "key").

ProjectFeatureFlagfeatureFlag = featureFlagService
.getProjectFeatureFlag(project, featureFlagName);

Create new project's feature flag.

ProjectFeatureFlagfeatureFlag = featureFlagService
.createProjectFeatureFlag(project, newProjectFeatureFlag(featureFlagName));

Update existing project's feature flag (please note that propagation of these changes may take some time).

ProjectFeatureFlagupdatedFeatureFlag = featureFlagService
.updateProjectFeatureFlag(featureFlagWithChangedValue);

Delete existing project's feature flag.

featureFlagService.deleteFeatureFlag(featureFlag);

Notification API

Create, Delete notification channels, subscriptions,...

Create notification channel

notificationService.createChannel(account,
newChannel(newEmailConfiguration("some@email.com"),
"channel name")
);

Delete notification channel

notificationService.removeChannel(channel);

Create notification subscription

notificationService.createSubscription(project,
account,
newSubscription(Collections.singletonList(newTimerEvent("0 * * * * *")),
Collections.singletonList(channel),
newTriggerCondition("true"),
newMessageTemplate("some message"),
"test subscription"
)
);

Delete notification subscription

notificationService.removeSubscription(subscription);

Logout

Logout from GoodData Platform.

gd.logout();

Clone this wiki locally