|
1 | | -using System; |
2 | | -using System.Reflection; |
3 | | -using System.Runtime.InteropServices; |
4 | | - |
5 | | -namespace Snowflake.Data.Core |
6 | | -{ |
7 | | - internal static class RestParams |
8 | | - { |
9 | | - internal const string SF_QUERY_WAREHOUSE = "warehouse"; |
10 | | - |
11 | | - internal const string SF_QUERY_DB = "databaseName"; |
12 | | - |
13 | | - internal const string SF_QUERY_SCHEMA = "schemaName"; |
14 | | - |
15 | | - internal const string SF_QUERY_ROLE = "roleName"; |
16 | | - |
17 | | - internal const string SF_QUERY_REQUEST_ID = "requestId"; |
18 | | - |
19 | | - internal const string SF_QUERY_REQUEST_GUID = "request_guid"; |
20 | | - |
21 | | - internal const string SF_QUERY_START_TIME = "clientStartTime"; |
22 | | - |
23 | | - internal const string SF_QUERY_RETRY_COUNT = "retryCount"; |
24 | | - |
25 | | - internal const string SF_QUERY_RETRY_REASON = "retryReason"; |
26 | | - |
27 | | - internal const string SF_QUERY_SESSION_DELETE = "delete"; |
28 | | - } |
29 | | - |
30 | | - internal static class RestPath |
31 | | - { |
32 | | - internal const string SF_SESSION_PATH = "/session"; |
33 | | - |
34 | | - internal const string SF_LOGIN_PATH = SF_SESSION_PATH + "/v1/login-request"; |
35 | | - |
36 | | - internal const string SF_TOKEN_REQUEST_PATH = SF_SESSION_PATH + "/token-request"; |
37 | | - |
38 | | - internal const string SF_AUTHENTICATOR_REQUEST_PATH = SF_SESSION_PATH + "/authenticator-request"; |
39 | | - |
40 | | - internal const string SF_QUERY_PATH = "/queries/v1/query-request"; |
41 | | - |
42 | | - internal const string SF_MONITOR_QUERY_PATH = "/monitoring/queries/"; |
43 | | - |
44 | | - internal const string SF_SESSION_HEARTBEAT_PATH = SF_SESSION_PATH + "/heartbeat"; |
45 | | - |
46 | | - internal const string SF_CONSOLE_LOGIN = "/console/login"; |
47 | | - } |
48 | | - |
49 | | - internal static class OAuthFlowConfig |
50 | | - { |
51 | | - internal const string SnowflakeAuthorizeUrl = "/oauth/authorize"; |
52 | | - internal const string SnowflakeTokenUrl = "/oauth/token-request"; |
53 | | - internal const string DefaultScopePrefixBeforeRole = "session:role:"; |
54 | | - } |
55 | | - |
56 | | - internal static class OktaUrl |
57 | | - { |
58 | | - internal const string DOMAIN = "okta.com"; |
59 | | - internal const string SSO_SAML_PATH = "/sso/saml"; |
60 | | - } |
61 | | - |
62 | | - internal class SFEnvironment |
63 | | - { |
64 | | - static SFEnvironment() |
65 | | - { |
66 | | - ClientEnv = new LoginRequestClientEnv() |
67 | | - { |
68 | | - processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName, |
69 | | - osVersion = Environment.OSVersion.VersionString, |
70 | | - netRuntime = ExtractRuntime(), |
71 | | - netVersion = ExtractVersion(), |
72 | | - }; |
73 | | - |
74 | | - DriverVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); |
75 | | - DriverName = ".NET"; |
76 | | - } |
77 | | - |
78 | | - //temporary change for pretend as ODBC |
79 | | - internal static string DriverName { get; set; } |
80 | | - internal static string DriverVersion { get; set; } |
81 | | - internal static LoginRequestClientEnv ClientEnv { get; private set; } |
82 | | - |
83 | | - internal static string ExtractRuntime() |
84 | | - { |
85 | | - return RuntimeInformation.FrameworkDescription.Substring(0, RuntimeInformation.FrameworkDescription.LastIndexOf(' ')).Replace(" ", ""); |
86 | | - } |
87 | | - |
88 | | - internal static string ExtractVersion() |
89 | | - { |
90 | | - var version = RuntimeInformation.FrameworkDescription.Substring(RuntimeInformation.FrameworkDescription.LastIndexOf(' ')).Replace(" ", ""); |
91 | | - int secondPeriodIndex = version.IndexOf('.', version.IndexOf('.') + 1); |
92 | | - return version.Substring(0, secondPeriodIndex); |
93 | | - } |
94 | | - } |
95 | | -} |
| 1 | +using System; |
| 2 | +using System.Reflection; |
| 3 | +using System.Runtime.InteropServices; |
| 4 | + |
| 5 | +namespace Snowflake.Data.Core |
| 6 | +{ |
| 7 | + internal static class RestParams |
| 8 | + { |
| 9 | + internal const string SF_QUERY_WAREHOUSE = "warehouse"; |
| 10 | + |
| 11 | + internal const string SF_QUERY_DB = "databaseName"; |
| 12 | + |
| 13 | + internal const string SF_QUERY_SCHEMA = "schemaName"; |
| 14 | + |
| 15 | + internal const string SF_QUERY_ROLE = "roleName"; |
| 16 | + |
| 17 | + internal const string SF_QUERY_REQUEST_ID = "requestId"; |
| 18 | + |
| 19 | + internal const string SF_QUERY_REQUEST_GUID = "request_guid"; |
| 20 | + |
| 21 | + internal const string SF_QUERY_START_TIME = "clientStartTime"; |
| 22 | + |
| 23 | + internal const string SF_QUERY_RETRY_COUNT = "retryCount"; |
| 24 | + |
| 25 | + internal const string SF_QUERY_RETRY_REASON = "retryReason"; |
| 26 | + |
| 27 | + internal const string SF_QUERY_SESSION_DELETE = "delete"; |
| 28 | + } |
| 29 | + |
| 30 | + internal static class RestPath |
| 31 | + { |
| 32 | + internal const string SF_SESSION_PATH = "/session"; |
| 33 | + |
| 34 | + internal const string SF_LOGIN_PATH = SF_SESSION_PATH + "/v1/login-request"; |
| 35 | + |
| 36 | + internal const string SF_TOKEN_REQUEST_PATH = SF_SESSION_PATH + "/token-request"; |
| 37 | + |
| 38 | + internal const string SF_AUTHENTICATOR_REQUEST_PATH = SF_SESSION_PATH + "/authenticator-request"; |
| 39 | + |
| 40 | + internal const string SF_QUERY_PATH = "/queries/v1/query-request"; |
| 41 | + |
| 42 | + internal const string SF_MONITOR_QUERY_PATH = "/monitoring/queries/"; |
| 43 | + |
| 44 | + internal const string SF_SESSION_HEARTBEAT_PATH = SF_SESSION_PATH + "/heartbeat"; |
| 45 | + |
| 46 | + internal const string SF_CONSOLE_LOGIN = "/console/login"; |
| 47 | + } |
| 48 | + |
| 49 | + internal static class OAuthFlowConfig |
| 50 | + { |
| 51 | + internal const string SnowflakeAuthorizeUrl = "/oauth/authorize"; |
| 52 | + internal const string SnowflakeTokenUrl = "/oauth/token-request"; |
| 53 | + internal const string DefaultScopePrefixBeforeRole = "session:role:"; |
| 54 | + } |
| 55 | + |
| 56 | + internal static class OktaUrl |
| 57 | + { |
| 58 | + internal const string DOMAIN = "okta.com"; |
| 59 | + internal const string SSO_SAML_PATH = "/sso/saml"; |
| 60 | + } |
| 61 | + |
| 62 | + internal class SFEnvironment |
| 63 | + { |
| 64 | + static SFEnvironment() |
| 65 | + { |
| 66 | + ClientEnv = new LoginRequestClientEnv() |
| 67 | + { |
| 68 | + processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName, |
| 69 | + osVersion = Environment.OSVersion.VersionString, |
| 70 | + netRuntime = ExtractRuntime(), |
| 71 | + netVersion = ExtractVersion(), |
| 72 | + applicationPath = ExtractApplicationPath(), |
| 73 | + }; |
| 74 | + |
| 75 | + DriverVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); |
| 76 | + DriverName = ".NET"; |
| 77 | + } |
| 78 | + |
| 79 | + //temporary change for pretend as ODBC |
| 80 | + internal static string DriverName { get; set; } |
| 81 | + internal static string DriverVersion { get; set; } |
| 82 | + internal static LoginRequestClientEnv ClientEnv { get; private set; } |
| 83 | + |
| 84 | + internal static string ExtractRuntime() |
| 85 | + { |
| 86 | + return RuntimeInformation.FrameworkDescription.Substring(0, RuntimeInformation.FrameworkDescription.LastIndexOf(' ')).Replace(" ", ""); |
| 87 | + } |
| 88 | + |
| 89 | + internal static string ExtractVersion() |
| 90 | + { |
| 91 | + var version = RuntimeInformation.FrameworkDescription.Substring(RuntimeInformation.FrameworkDescription.LastIndexOf(' ')).Replace(" ", ""); |
| 92 | + int secondPeriodIndex = version.IndexOf('.', version.IndexOf('.') + 1); |
| 93 | + return version.Substring(0, secondPeriodIndex); |
| 94 | + } |
| 95 | + |
| 96 | + internal static string ExtractApplicationPath() |
| 97 | + { |
| 98 | + try |
| 99 | + { |
| 100 | + var assembly = Assembly.GetEntryAssembly(); |
| 101 | + if (assembly != null && !string.IsNullOrEmpty(assembly.Location)) |
| 102 | + { |
| 103 | + return assembly.Location; |
| 104 | + } |
| 105 | + |
| 106 | + var process = System.Diagnostics.Process.GetCurrentProcess(); |
| 107 | + var mainModule = process.MainModule; |
| 108 | + if (mainModule != null && !string.IsNullOrEmpty(mainModule.FileName)) |
| 109 | + { |
| 110 | + return mainModule.FileName; |
| 111 | + } |
| 112 | + |
| 113 | + return "UNKNOWN"; |
| 114 | + } |
| 115 | + catch (Exception) |
| 116 | + { |
| 117 | + return "UNKNOWN"; |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | +} |
0 commit comments