use of com.google.spanner.v1.DeleteSessionRequest in project java-spanner by googleapis.
the class SpannerClient method deleteSession.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Ends a session, releasing server resources associated with it. This will asynchronously trigger
* cancellation of any operations that are running with this session.
*
* <p>Sample code:
*
* <pre>{@code
* try (SpannerClient spannerClient = SpannerClient.create()) {
* String name = SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]").toString();
* spannerClient.deleteSession(name);
* }
* }</pre>
*
* @param name Required. The name of the session to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteSession(String name) {
DeleteSessionRequest request = DeleteSessionRequest.newBuilder().setName(name).build();
deleteSession(request);
}
use of com.google.spanner.v1.DeleteSessionRequest in project java-spanner by googleapis.
the class SpannerClient method deleteSession.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Ends a session, releasing server resources associated with it. This will asynchronously trigger
* cancellation of any operations that are running with this session.
*
* <p>Sample code:
*
* <pre>{@code
* try (SpannerClient spannerClient = SpannerClient.create()) {
* SessionName name = SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* spannerClient.deleteSession(name);
* }
* }</pre>
*
* @param name Required. The name of the session to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteSession(SessionName name) {
DeleteSessionRequest request = DeleteSessionRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteSession(request);
}
use of com.google.spanner.v1.DeleteSessionRequest in project java-spanner by googleapis.
the class SpannerClientTest method deleteSessionTest2.
@Test
public void deleteSessionTest2() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockSpanner.addResponse(expectedResponse);
String name = "name3373707";
client.deleteSession(name);
List<AbstractMessage> actualRequests = mockSpanner.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteSessionRequest actualRequest = ((DeleteSessionRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations