org.openqa.selenium.devtools.v85.database.Database Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium-devtools-v85 Show documentation
Show all versions of selenium-devtools-v85 Show documentation
Selenium automates browsers. That's it! What you do with that power is entirely up to you.
package org.openqa.selenium.devtools.v85.database;
import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import com.google.common.collect.ImmutableMap;
import org.openqa.selenium.json.JsonInput;
@Beta()
public class Database {
/**
* Disables database tracking, prevents database events from being sent to the client.
*/
public static Command disable() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Database.disable", params.build());
}
/**
* Enables database tracking, database events will now be delivered to the client.
*/
public static Command enable() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Database.enable", params.build());
}
public static class ExecuteSQLResponse {
private final java.util.Optional> columnNames;
private final java.util.Optional> values;
private final java.util.Optional sqlError;
public ExecuteSQLResponse(java.util.Optional> columnNames, java.util.Optional> values, java.util.Optional sqlError) {
this.columnNames = columnNames;
this.values = values;
this.sqlError = sqlError;
}
public java.util.Optional> getColumnNames() {
return columnNames;
}
public java.util.Optional> getValues() {
return values;
}
public java.util.Optional getSqlError() {
return sqlError;
}
private static ExecuteSQLResponse fromJson(JsonInput input) {
java.util.Optional> columnNames = java.util.Optional.empty();
java.util.Optional> values = java.util.Optional.empty();
java.util.Optional sqlError = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "columnNames":
columnNames = java.util.Optional.ofNullable(input.read(new com.google.common.reflect.TypeToken>() {
}.getType()));
break;
case "values":
values = java.util.Optional.ofNullable(input.read(new com.google.common.reflect.TypeToken>() {
}.getType()));
break;
case "sqlError":
sqlError = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v85.database.model.Error.class));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new ExecuteSQLResponse(columnNames, values, sqlError);
}
}
public static Command executeSQL(org.openqa.selenium.devtools.v85.database.model.DatabaseId databaseId, java.lang.String query) {
java.util.Objects.requireNonNull(databaseId, "databaseId is required");
java.util.Objects.requireNonNull(query, "query is required");
ImmutableMap.Builder params = ImmutableMap.builder();
params.put("databaseId", databaseId);
params.put("query", query);
return new Command<>("Database.executeSQL", params.build(), input -> input.read(org.openqa.selenium.devtools.v85.database.Database.ExecuteSQLResponse.class));
}
public static Command> getDatabaseTableNames(org.openqa.selenium.devtools.v85.database.model.DatabaseId databaseId) {
java.util.Objects.requireNonNull(databaseId, "databaseId is required");
ImmutableMap.Builder params = ImmutableMap.builder();
params.put("databaseId", databaseId);
return new Command<>("Database.getDatabaseTableNames", params.build(), ConverterFunctions.map("tableNames", new com.google.common.reflect.TypeToken>() {
}.getType()));
}
public static Event addDatabase() {
return new Event<>("Database.addDatabase", ConverterFunctions.map("database", org.openqa.selenium.devtools.v85.database.model.Database.class));
}
}