示例#1
0
        /// <summary>
        /// Initializes new Snowflake session.
        /// </summary>
        /// <returns>True if session succesfully initialized</returns>
        public async Task <bool> InitNewSessionAsync()
        {
            _session = await AuthenticateAsync(_clientSettings.AuthInfo, _clientSettings.SessionInfo).ConfigureAwait(false);

            _requestBuilder.SetSessionTokens(_session.SessionToken, _session.MasterToken);

            return(true);
        }
示例#2
0
        /// <summary>
        /// Closes current Snowflake session.
        /// </summary>
        /// <returns>True if session was successfully closed.</returns>
        public async Task <bool> CloseSessionAsync()
        {
            var closeSessionRequest = _requestBuilder.BuildCloseSessionRequest();
            var response            = await _restClient.SendAsync <CloseResponse>(closeSessionRequest).ConfigureAwait(false);

            _session = null;
            _requestBuilder.ClearSessionTokens();

            if (!response.Success)
            {
                throw new SnowflakeException($"Closing session failed. Message: {response.Message}", response.Code);
            }

            return(response.Success);
        }