forked from databricks/databricks-sql-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.py
More file actions
40 lines (33 loc) · 937 Bytes
/
http.py
File metadata and controls
40 lines (33 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
from enum import Enum
import threading
from dataclasses import dataclass
from contextlib import contextmanager
from typing import Generator, Optional
import logging
from requests.adapters import HTTPAdapter
from databricks.sql.auth.retry import DatabricksRetryPolicy, CommandType
logger = logging.getLogger(__name__)
# Enums for HTTP Methods
class HttpMethod(str, Enum):
GET = "GET"
POST = "POST"
PUT = "PUT"
DELETE = "DELETE"
# HTTP request headers
class HttpHeader(str, Enum):
CONTENT_TYPE = "Content-Type"
AUTHORIZATION = "Authorization"
# Dataclass for OAuthHTTP Response
@dataclass
class OAuthResponse:
token_type: str = ""
expires_in: int = 0
ext_expires_in: int = 0
expires_on: int = 0
not_before: int = 0
resource: str = ""
access_token: str = ""
refresh_token: str = ""