Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Feature/lattice 2228 external atlas access #359

Merged
merged 78 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
b6e19e4
started building crud apis for atlas raw data
Oct 4, 2019
90eea5a
Added atlasdbs as securable object type
Oct 4, 2019
bfdd933
created securable object ATlasDatabase
Oct 4, 2019
3d0df44
moved api from organizations to permissions
Oct 4, 2019
6532c03
Added more securable object classes
Oct 7, 2019
a8d7587
Merge branch 'develop' into feature/LATTICE-2228-external-atlas-access
Oct 7, 2019
4c82680
more securable object things
Oct 8, 2019
74aea1c
Added table id to column securable object and made some creation apis
Oct 8, 2019
7e02b11
messy progress
Oct 10, 2019
ef1f7c5
renamed from atlas to externaldatabase
Oct 10, 2019
7be924f
renamed api from atlas to external database
Oct 10, 2019
d13669e
more renaming from atlas to externaldatabase
Oct 10, 2019
ae37367
added GET apis for column and table objects
Oct 11, 2019
80cf21d
added update apis
Oct 11, 2019
48d8914
delete apis
Oct 11, 2019
dc3b0e8
Merge branch 'develop' into feature/LATTICE-2228-external-atlas-access
Oct 15, 2019
3f943ed
added api for batch delete of tables
Oct 15, 2019
fce0166
added apis for batch delete of columns
Oct 15, 2019
cbc8a73
typo
Oct 15, 2019
0afdbe7
fixed testdatafactor instantiation of column and table objects
Oct 15, 2019
2c0aa41
forgot the ;
Oct 15, 2019
d78e074
formatting and docs
Oct 16, 2019
ae65a4b
Added apis for created a new table or column in an org's database
Oct 16, 2019
7421f94
leftover renaming
Oct 17, 2019
3844144
api for setting primary key
Oct 18, 2019
d86447e
remove ip address param
Oct 19, 2019
e752d15
added endpoint field
Oct 19, 2019
1a807c4
added datatype and primary key to column securable object
Oct 19, 2019
8924e8b
hopefully the last renaming
Oct 22, 2019
6d4eb74
added ordinal position to column objects
Oct 22, 2019
d80dd23
removed dedicated updateAcls api
Oct 22, 2019
e1f0d9a
removed unnecessary apis
Oct 22, 2019
444d164
added enum of owner privileges on postgres
Oct 23, 2019
91c086c
confused
Oct 23, 2019
3794f99
moved apis to dedicated interface
Oct 23, 2019
ad41727
more cleanup
Oct 23, 2019
443ed63
moved file
Oct 25, 2019
781e3d2
renamed enum to reflect usage
Oct 25, 2019
94def38
added useful apis for orgs app
Oct 25, 2019
796d791
updated api return types
Oct 28, 2019
0bdd6b6
added row count arg and allow for null values to be read from postgres
Oct 28, 2019
c1017c7
added function to get the id of a securable object from an aclKey
Oct 29, 2019
b17c4e7
added ALL as a postgres privilege
Oct 30, 2019
2228123
removed complicated index to use more straightforward one
Oct 30, 2019
2b5fad8
removed apis that shouldn't be accessible outside of indexer
Oct 30, 2019
d805025
added class to store hba records
Oct 31, 2019
a288767
hba records things
Oct 31, 2019
418703d
change var name to username
Oct 31, 2019
dd14cc7
removed auth method as path var in api
Oct 31, 2019
c142209
remove trusted user api
Oct 31, 2019
eb03013
remove ip mask, add connection type, make ip addresses a set
Nov 1, 2019
8722846
renamed function from trustedUser to hbaRecord
Nov 5, 2019
78f8507
removed jsonCreator annotation and moved docs
Nov 5, 2019
9f14e4b
return two field object instead of a pair
Nov 5, 2019
39a5f28
constants for new two field class
Nov 5, 2019
f23b297
data class for holding an org table object and its column objects
Nov 5, 2019
e50f924
expanded doc
Nov 5, 2019
55b8f12
renamed api
Nov 5, 2019
b1aac98
removed unused constant
Nov 5, 2019
ca92fea
Merge branch 'develop' into feature/LATTICE-2228-external-atlas-access
Nov 5, 2019
8170ea8
removed unused consts
Nov 5, 2019
9d756b4
fixed docs
Nov 5, 2019
418773f
Merge branch 'feature/LATTICE-2228-external-atlas-access' of github.c…
Nov 5, 2019
bbb773e
added docs
Nov 6, 2019
1e7867c
renamed isPrimaryKey to primaryKey
Nov 6, 2019
e222bc6
enum of postgres connection types
Nov 13, 2019
31a87f6
use enum instead of string
Nov 13, 2019
f2ea833
use enum for postgres datatype
Nov 14, 2019
d1c6b27
enum for connection type
Nov 14, 2019
cf78bca
single ip address, new line in hba record, psql insert query for hba …
Nov 15, 2019
b3af6a5
updated adding and removing hba records
Nov 15, 2019
bebb6ca
remove value ALL from enum
Nov 16, 2019
9bf12e9
nvm
Nov 16, 2019
da70248
Merge branch 'develop' into feature/LATTICE-2228-external-atlas-access
Nov 25, 2019
26ec904
move consts out of companion object
Nov 25, 2019
802bd3a
Merge branch 'feature/LATTICE-2228-external-atlas-access' of github.c…
Nov 25, 2019
c220362
conflix
Nov 25, 2019
9376892
Merge branch 'develop' into feature/LATTICE-2228-external-atlas-access
geekbeast Nov 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

import retrofit2.http.*;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* @author Ho Chung Siu
Expand All @@ -36,8 +34,12 @@ public interface PermissionsApi {
String CONTROLLER = "/permissions";
String BASE = SERVICE + CONTROLLER;

String EXPLAIN = "/explain";
String UPDATE = "/update";
String EXPLAIN = "/explain";
String UPDATE = "/update";

String ID = "id";
pckeyes marked this conversation as resolved.
Show resolved Hide resolved
String ID_PATH = "/{" + ID + "}";


/**
* Adds, removes, or sets the ace for a particular acl key. Successful only if user is the owner of acl key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ public enum SecurableObjectType {
AppType,
Principal,
Role,
Unknown
Unknown,
OrganizationExternalDatabaseTable,
OrganizationExternalDatabaseColumn
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public final class SerializationConstants {
public static final String CHILD_CLAUSES = "childClauses";
public static final String CHILD_QUERIES = "childQueries";
public static final String CLAUSES = "clauses";
public static final String COLUMNS = "columns";
public static final String COLUMN_IDS_BY_TABLE_ID = "columnIdsByTableId";
public static final String COMPARISON = "comparison";
public static final String CONFIG = "config";
public static final String CONFLICTS = "conflicts";
Expand Down Expand Up @@ -142,6 +144,7 @@ public final class SerializationConstants {
public static final String IS_DESCENDING = "isDescending";
pckeyes marked this conversation as resolved.
Show resolved Hide resolved
public static final String IS_DST = "isDst";
public static final String IS_OWNER = "isOwner";
public static final String IS_PRIMARY_KEY = "isPrimaryKey";
public static final String KEYWORD = "kw";
public static final String KEY_FIELD = "key";
public static final String LAST_INDEX = "lastIndex";
Expand Down Expand Up @@ -188,6 +191,7 @@ public final class SerializationConstants {
public static final String PERMISSIONS_MAP = "permissionsMap";
public static final String PHONE_NUMBER = "phoneNumber";
public static final String PII_FIELD = "pii";
public static final String ORDINAL_POSITION = "ordinalPosition";
public static final String PRESENT = "present";
public static final String PRINCIPAL = "principal";
public static final String PRINCIPAL_PATHS = "principalPaths";
Expand Down Expand Up @@ -232,6 +236,7 @@ public final class SerializationConstants {
public static final String SYNC_IDS = "syncIds";
public static final String SYNC_TICKETS = "syncTickets";
public static final String TAGS = "tags";
public static final String TABLE_ID = "tableId";
public static final String TARGET = "target";
public static final String TEMPLATE = "template";
public static final String TIMESTAMP = "timestamp";
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/openlattice/mapstores/TestDataFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import com.openlattice.edm.type.EntityType;
import com.openlattice.edm.type.PropertyType;
import com.openlattice.organization.Organization;
import com.openlattice.organization.OrganizationExternalDatabaseColumn;
import com.openlattice.organization.OrganizationExternalDatabaseTable;
import com.openlattice.organization.roles.Role;
import com.openlattice.postgres.IndexType;
import com.openlattice.requests.PermissionsRequestDetails;
Expand Down Expand Up @@ -585,4 +587,30 @@ public static EntitySetCollection entitySetCollection() {
);
}

public static OrganizationExternalDatabaseColumn organizationExternalDatabaseColumn() {
OrganizationExternalDatabaseTable table = organizationExternalDatabaseTable();
return new OrganizationExternalDatabaseColumn(
UUID.randomUUID(),
randomAlphanumeric( 5 ),
randomAlphanumeric( 5 ),
Optional.of(randomAlphanumeric( 5 )),
table.getId(),
UUID.randomUUID(),
randomAlphabetic( 5 ),
r.nextBoolean(),
r.nextInt( 1000 )
);
}


public static OrganizationExternalDatabaseTable organizationExternalDatabaseTable() {
return new OrganizationExternalDatabaseTable(
UUID.randomUUID(),
randomAlphanumeric( 5 ),
randomAlphanumeric( 5 ),
Optional.of(randomAlphanumeric( 5 )),
UUID.randomUUID()
);
}

}
30 changes: 11 additions & 19 deletions src/main/java/com/openlattice/organization/OrganizationsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,14 @@
package com.openlattice.organization;

import com.openlattice.directory.pojo.Auth0UserBasic;
import com.openlattice.notifications.sms.SmsEntitySetInformation;
import com.openlattice.organization.roles.Role;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;

import java.util.*;

import retrofit2.http.*;

public interface OrganizationsApi {
String ASSEMBLE = "/assemble";
String ASSEMBLE = "/assemble";
String CONTROLLER = "/organizations";
String DESCRIPTION = "/description";
String EMAIL_DOMAIN = "email-domain";
Expand All @@ -53,11 +44,12 @@ public interface OrganizationsApi {
String PRINCIPALS = "/principals";
String PRINCIPAL_ID = "pid";
String PRINCIPAL_ID_PATH = "/{" + PRINCIPAL_ID + "}";
String REFRESH = "/refresh";
String REFRESH_RATE = "/refresh-rate";
String REFRESH = "/refresh";
String REFRESH_RATE = "/refresh-rate";
String ROLES = "/roles";
String ROLE_ID = "roleId";
String ROLE_ID_PATH = "/{" + ROLE_ID + "}";
String ROLE_ID = "roleId";
String ROLE_ID_PATH = "/{" + ROLE_ID + "}";

/*
* These determine the service routing for the LB
*/
Expand Down Expand Up @@ -258,4 +250,4 @@ Void removeRoleFromUser(
@Path( ROLE_ID ) UUID roleId,
@Path( USER_ID ) String userId );

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package com.openlattice.organization

import retrofit2.http.*
import java.util.*

interface OrganizationExternalDatabaseApi {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just DatasetApi?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use "OrganizationExternalDatabase" all over the place in this feature, was trying to keep it consistent. I'm happy to change it though, I realize it's a super verbose name.


companion object {
/* These determine the service routing */
const val SERVICE = "/datastore"
const val CONTROLLER = "/organization-database"
const val BASE = SERVICE + CONTROLLER

const val EXTERNAL_DATABASE = "/external-database"
const val EXTERNAL_DATABASE_COLUMN = "/external-database-column"
const val EXTERNAL_DATABASE_TABLE = "/external-database-table"

const val ID = "id"
const val ID_PATH = "/{$ID}"
const val TABLE_NAME = "tableName"
const val TABLE_NAME_PATH = "/{$TABLE_NAME}"
const val COLUMN_NAME = "columnName"
const val COLUMN_NAME_PATH = "/{$COLUMN_NAME}"
const val SQL_TYPE = "sqlType"
const val SQL_TYPE_PATH = "/{$SQL_TYPE}"
const val USER_ID = "userId"
const val USER_ID_PATH = "/{$USER_ID:.*}"
}

//create
/**
* Creates a securable OrganizationExternalDatabaseTable object, which represents an
* organization's table in an external database. The table must already exist in the database
* @param organizationId The organization's UUID
* @param organizationExternalDatabaseTable The object to be created
*/
@POST(BASE + ID_PATH + EXTERNAL_DATABASE_TABLE)
fun createExternalDatabaseTable(@Path(ID) organizationId: UUID,
@Body organizationExternalDatabaseTable: OrganizationExternalDatabaseTable): UUID

/**
* Creates a securable OrganizationExternalDatabaseColumn object, which represents a
* column within an organization's table in an external database. The table and column must
* already exist in the database
* @param organizationId The organization's UUID
* @param organizationExternalDatabaseColumn The object to be created
*/
@POST(BASE + ID_PATH + EXTERNAL_DATABASE_COLUMN)
fun createExternalDatabaseColumn(@Path(ID) organizationId: UUID,
@Body organizationExternalDatabaseColumn: OrganizationExternalDatabaseColumn): UUID

/**
*
* @param organizationId The organization's UUID
* @param userId The user to be given trusted status
* @param ipAddresses The set of ip addresses (as strings) from which users will be trusted
*/
@POST(BASE + ID_PATH + USER_ID_PATH + EXTERNAL_DATABASE)
fun addTrustedUser(
@Path(ID) organizationId: UUID,
@Path(USER_ID) userId: String,
@Body ipAddresses: Set<String>)

//get
/**
* Gets an OrganizationExternalDatabaseTable object, which represents an
* organization's table in an external database
* @param organizationId The organization's UUID
* @param tableName The exact name of the table in the database
*/
@GET(BASE + ID_PATH + TABLE_NAME_PATH + EXTERNAL_DATABASE_TABLE)
fun getExternalDatabaseTable(
@Path(ID) organizationId: UUID, @Path(TABLE_NAME) tableName: String): OrganizationExternalDatabaseTable

/**
* Gets an OrganizationExternalDatabaseColumn object, which represents a column
* within an organization's table in an external database
* @param organizationId The organization's UUID
* @param tableName The exact name of the table in the database
* @param columnName The exact name of the column in the database
*/
@GET(BASE + ID_PATH + TABLE_NAME_PATH + COLUMN_NAME_PATH + EXTERNAL_DATABASE_COLUMN)
fun getExternalDatabaseColumn(
@Path(ID) organizationId: UUID, @Path(TABLE_NAME) tableName: String, @Path(COLUMN_NAME) columnName: String): OrganizationExternalDatabaseColumn


//delete
/**
* Deletes an OrganizationExternalDatabaseTable object, which represents an
* organization's table in an external database. This deletes both the object
* and the table in the database. It is a hard delete
* @param organizationId The organization's UUID
* @param tableName The exact name of the table in the database
*/
@DELETE(BASE + ID_PATH + TABLE_NAME_PATH + EXTERNAL_DATABASE_TABLE)
fun deleteExternalDatabaseTable(
@Path(ID) organizationId: UUID,
@Path(TABLE_NAME) tableName: String)

/**
* Deletes an OrganizationExternalDatabaseColumn object, which represents a column
* within an organization's table in an external database. This deletes both the object
* and the column in the database. It is a hard delete
* @param organizationId The organization's UUID
* @param tableName The exact name of the table in the database
* @param columnName The exact name of the column in the database
*/
@DELETE(BASE + ID_PATH + TABLE_NAME_PATH + COLUMN_NAME_PATH + EXTERNAL_DATABASE_COLUMN)
fun deleteExternalDatabaseColumn(
@Path(ID) organizationId: UUID,
@Path(TABLE_NAME) tableName: String,
@Path(COLUMN_NAME) columnName: String)

/**
* Deletes multiple OrganizationExternalDatabaseTable objects and the tables they represent
* in the database. It is a hard delete
* @param organizationId The organization's UUID
* @param tableNames The exact names of the tables in the database
*/
@DELETE(BASE + ID_PATH + EXTERNAL_DATABASE_TABLE)
fun deleteExternalDatabaseTables(
@Path(ID) organizationId: UUID,
@Body tableNames: Set<String>)

/**
* Deletes multiple OrganizationExternalDatabaseColumn objects and the columns they represent
* within an organization's table in an external database. It is a hard delete
* @param organizationId The organization's UUID
* @param tableName The exact name of the table in the database
* @param columnNames The exact names of the columns in the database
*/
@DELETE(BASE + ID_PATH + TABLE_NAME_PATH + EXTERNAL_DATABASE_COLUMN)
fun deleteExternalDatabaseColumns(
@Path(ID) organizationId: UUID,
@Path(TABLE_NAME) tableName: String,
@Body columnNames: Set<String>)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.openlattice.organization

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import com.openlattice.authorization.securable.AbstractSecurableObject
import com.openlattice.authorization.securable.SecurableObjectType
import com.openlattice.client.serialization.SerializationConstants
import org.apache.olingo.commons.api.edm.FullQualifiedName
import java.util.*

class OrganizationExternalDatabaseColumn

/**
* Creates a securable object for an organization's entire database in Atlas
*
* @param id An optional UUID that will be automatically generated if not provided
* @param name The name of the column
* @param title A title for the object
* @param description A description for the object
* @param tableId The id of the table that contains this column
* @param organizationId The id of the organization that owns this column
pckeyes marked this conversation as resolved.
Show resolved Hide resolved
*/

@JsonCreator
pckeyes marked this conversation as resolved.
Show resolved Hide resolved
constructor(
@JsonProperty(SerializationConstants.ID_FIELD) id: Optional<UUID>,
@JsonProperty(SerializationConstants.NAME_FIELD) var name: String,
@JsonProperty(SerializationConstants.TITLE_FIELD) title: String,
@JsonProperty(SerializationConstants.DESCRIPTION_FIELD) description: Optional<String>,
@JsonProperty(SerializationConstants.TABLE_ID) var tableId: UUID,
@JsonProperty(SerializationConstants.ORGANIZATION_ID) var organizationId: UUID,
@JsonProperty(SerializationConstants.DATATYPE_FIELD) var dataType: String,
@JsonProperty(SerializationConstants.IS_PRIMARY_KEY) var isPrimaryKey: Boolean,
pckeyes marked this conversation as resolved.
Show resolved Hide resolved
@JsonProperty(SerializationConstants.ORDINAL_POSITION) var ordinalPosition: Int
) : AbstractSecurableObject(id, title, description) {

constructor(
id: UUID,
name: String,
title: String,
description: Optional<String>,
tableId: UUID,
organizationId: UUID,
dataType: String,
isPrimaryKey: Boolean,
ordinalPosition: Int
) : this(Optional.of(id), name, title, description, tableId, organizationId, dataType, isPrimaryKey, ordinalPosition)

@JsonIgnore
override fun getCategory(): SecurableObjectType {
return SecurableObjectType.OrganizationExternalDatabaseColumn
}
}
Loading