private SFRestRequest BuildCancelQueryRequest() { lock (_requestIdLock) { if (_requestId == null) { return(null); } Dictionary <string, string> parameters = new Dictionary <string, string>() { { RestParams.SF_QUERY_REQUEST_ID, Guid.NewGuid().ToString() }, { RestParams.SF_QUERY_REQUEST_GUID, Guid.NewGuid().ToString() }, }; var uri = SfSession.BuildUri(SF_QUERY_CANCEL_PATH, parameters); QueryCancelRequest postBody = new QueryCancelRequest() { requestId = _requestId }; return(new SFRestRequest(SfSession.InsecureMode) { Url = uri, authorizationToken = string.Format(SF_AUTHORIZATION_SNOWFLAKE_FMT, SfSession.sessionToken), jsonBody = postBody }); } }
private SFRestRequest BuildCancelQueryRequest() { lock (_requestIdLock) { if (_requestId == null) { return(null); } var uri = SfSession.BuildUri(SF_QUERY_CANCEL_PATH, new Dictionary <string, string> { { SF_QUERY_REQUEST_ID, Guid.NewGuid().ToString() } }); QueryCancelRequest postBody = new QueryCancelRequest() { requestId = _requestId }; return(new SFRestRequest() { uri = uri, authorizationToken = string.Format(SF_AUTHORIZATION_SNOWFLAKE_FMT, SfSession.sessionToken), jsonBody = postBody }); } }
internal void cancel() { if (this.requestId == null) { logger.Info("No query to be cancelled."); return; } UriBuilder uriBuilder = new UriBuilder(); uriBuilder.Scheme = sfSession.properties[SFSessionProperty.SCHEME]; uriBuilder.Host = sfSession.properties[SFSessionProperty.HOST]; uriBuilder.Port = Int32.Parse(sfSession.properties[SFSessionProperty.PORT]); uriBuilder.Path = SF_QUERY_CANCEL_PATH; var queryString = HttpUtility.ParseQueryString(string.Empty); queryString[SF_QUERY_REQUEST_ID] = Guid.NewGuid().ToString(); uriBuilder.Query = queryString.ToString(); QueryCancelRequest postBody = new QueryCancelRequest() { requestId = this.requestId }; SFRestRequest cancelRequest = new SFRestRequest(); cancelRequest.uri = uriBuilder.Uri; cancelRequest.authorizationToken = String.Format(SF_AUTHORIZATION_SNOWFLAKE_FMT, sfSession.sessionToken); cancelRequest.jsonBody = postBody; NullDataResponse cancelResponse = restRequest.post(cancelRequest).ToObject <NullDataResponse>(); if (cancelResponse.success) { logger.Info("Query cancellation succeed"); } else { SnowflakeDbException e = new SnowflakeDbException( "", cancelResponse.code, cancelResponse.message, ""); logger.Error("Query cancellation failed.", e); throw e; } }