Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright The Stargate Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.stargate.it.http.graphql.graphqlfirst;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
import com.jayway.jsonpath.JsonPath;
import io.stargate.it.http.RestUtils;
import io.stargate.it.http.graphql.GraphqlClient;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
public class GraphqlFirstClient extends GraphqlClient {
// Note: these constants duplicate the ones from the production code's `ResourcePaths` (which is
// not accessible from here).
private static final String ADMIN = "/graphql-admin";
private static final String KEYSPACES = "/graphql";
private static final String FILES = "/graphql-files";
private final String host;
private final String authToken;
private final String adminUri;
private final String cqlDirectivesUri;
public GraphqlFirstClient(String host, String authToken) {
this.host = host;
this.authToken = authToken;
this.adminUri = String.format("http://%s:8080%s", host, ADMIN);
this.cqlDirectivesUri = String.format("http://%s:8080%s/cql_directives.graphql", host, FILES);
}
/**
* Deploys new contents to a keyspace, assuming no previous version existed.
*
* @return the resulting version.
*/
public UUID deploySchema(String keyspace, String contents) {
return deploySchema(keyspace, null, contents);
}
public UUID deploySchema(String keyspace, String expectedVersion, String contents) {
return deploySchema(keyspace, expectedVersion, false, contents);
}
public UUID deploySchema(
String keyspace, String expectedVersion, boolean force, String contents) {
Map response =
getGraphqlData(
authToken,
adminUri,
buildDeploySchemaQuery(keyspace, expectedVersion, force, contents));
String version = JsonPath.read(response, "$.deploySchema.version");
return UUID.fromString(version);
}
/**
* Deploys new contents to a keyspace, assuming it will produce errors.
*
* @return the full contents of the {@code errors} field in the response.
*/
public List