use of com.google.firestore.admin.v1.Index in project java-datastore by googleapis.
the class DatastoreAdminClientTest method listIndexesTest.
@Test
public void listIndexesTest() throws Exception {
Index responsesElement = Index.newBuilder().build();
ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
mockDatastoreAdmin.addResponse(expectedResponse);
ListIndexesRequest request = ListIndexesRequest.newBuilder().setProjectId("projectId-894832108").setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();
ListIndexesPagedResponse pagedListResponse = client.listIndexes(request);
List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDatastoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.Index in project security by opensearch-project.
the class ConfigModelV7 method reload.
private SecurityRoles reload(SecurityDynamicConfiguration<RoleV7> settings) {
final Set<Future<SecurityRole>> futures = new HashSet<>(5000);
final ExecutorService execs = Executors.newFixedThreadPool(10);
for (Entry<String, RoleV7> securityRole : settings.getCEntries().entrySet()) {
Future<SecurityRole> future = execs.submit(new Callable<SecurityRole>() {
@Override
public SecurityRole call() throws Exception {
SecurityRole.Builder _securityRole = new SecurityRole.Builder(securityRole.getKey());
if (securityRole.getValue() == null) {
return null;
}
final Set<String> permittedClusterActions = agr.resolvedActions(securityRole.getValue().getCluster_permissions());
_securityRole.addClusterPerms(permittedClusterActions);
for (final Index permittedAliasesIndex : securityRole.getValue().getIndex_permissions()) {
final String dls = permittedAliasesIndex.getDls();
final List<String> fls = permittedAliasesIndex.getFls();
final List<String> maskedFields = permittedAliasesIndex.getMasked_fields();
for (String pat : permittedAliasesIndex.getIndex_patterns()) {
IndexPattern _indexPattern = new IndexPattern(pat);
_indexPattern.setDlsQuery(dls);
_indexPattern.addFlsFields(fls);
_indexPattern.addMaskedFields(maskedFields);
_indexPattern.addPerm(agr.resolvedActions(permittedAliasesIndex.getAllowed_actions()));
/*for(Entry<String, List<String>> type: permittedAliasesIndex.getValue().getTypes(-).entrySet()) {
TypePerm typePerm = new TypePerm(type.getKey());
final List<String> perms = type.getValue();
typePerm.addPerms(agr.resolvedActions(perms));
_indexPattern.addTypePerms(typePerm);
}*/
_securityRole.addIndexPattern(_indexPattern);
}
}
return _securityRole.build();
}
});
futures.add(future);
}
execs.shutdown();
try {
execs.awaitTermination(30, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("Thread interrupted (1) while loading roles");
return null;
}
try {
SecurityRoles _securityRoles = new SecurityRoles(futures.size());
for (Future<SecurityRole> future : futures) {
_securityRoles.addSecurityRole(future.get());
}
return _securityRoles;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("Thread interrupted (2) while loading roles");
return null;
} catch (ExecutionException e) {
log.error("Error while updating roles: {}", e.getCause(), e.getCause());
throw ExceptionsHelper.convertToOpenSearchException(e);
}
}
use of com.google.firestore.admin.v1.Index in project jaxdb by jaxdb.
the class DerbyDecompiler method getIndexes.
@Override
@SuppressWarnings("null")
Map<String, $Table.Indexes> getIndexes(final Connection connection) throws SQLException {
final Map<String, List<String>> tableNameToColumns = getTables(connection);
final PreparedStatement statement = connection.prepareStatement(indexSql);
final ResultSet rows = statement.executeQuery();
final Map<String, $Table.Indexes> tableNameToIndexes = new HashMap<>();
String lastTable = null;
$Table.Indexes indexes = null;
while (rows.next()) {
final String tableName = rows.getString(2);
final List<String> columnNames = tableNameToColumns.get(tableName);
if (!tableName.equals(lastTable)) {
lastTable = tableName;
tableNameToIndexes.put(tableName, indexes = new $Table.Indexes());
}
final String descriptor = rows.getString(3);
final boolean unique = descriptor.startsWith("UNIQUE");
final $IndexType.Enum type = descriptor.startsWith("HASH") ? $Index.Type$.HASH : $Index.Type$.BTREE;
final $Table.Indexes.Index index = new $Table.Indexes.Index();
indexes.addIndex(index);
if (!$Index.Type$.BTREE.equals(type))
index.setType$(new $Index.Type$(type));
if (unique)
index.setUnique$(new $Index.Unique$(unique));
final String[] columnNumbers = descriptor.substring(descriptor.lastIndexOf('(') + 1, descriptor.lastIndexOf(')')).split(",");
for (final String columnNumber : columnNumbers) {
final String columnName = columnNames.get(Integer.valueOf(columnNumber.trim()) - 1);
final $Table.Indexes.Index.Column column = new $Table.Indexes.Index.Column();
column.setName$(new $Table.Indexes.Index.Column.Name$(columnName.toLowerCase()));
index.addColumn(column);
}
}
return tableNameToIndexes;
}
use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.
the class FirestoreAdminClientTest method getIndexTest2.
@Test
public void getIndexTest2() throws Exception {
Index expectedResponse = Index.newBuilder().setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()).addAllFields(new ArrayList<Index.IndexField>()).build();
mockFirestoreAdmin.addResponse(expectedResponse);
String name = "name3373707";
Index actualResponse = client.getIndex(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.
the class FirestoreAdminClientTest method getIndexTest.
@Test
public void getIndexTest() throws Exception {
Index expectedResponse = Index.newBuilder().setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()).addAllFields(new ArrayList<Index.IndexField>()).build();
mockFirestoreAdmin.addResponse(expectedResponse);
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
Index actualResponse = client.getIndex(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations