cecil 0.0.17__py3-none-any.whl → 0.0.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cecil might be problematic. Click here for more details.

cecil/client.py CHANGED
@@ -6,6 +6,7 @@ import requests
6
6
  import snowflake.connector
7
7
  from pydantic import BaseModel
8
8
  from requests import auth
9
+ from cryptography.hazmat.primitives import serialization
9
10
 
10
11
  from .errors import (
11
12
  Error,
@@ -26,7 +27,7 @@ from .models import (
26
27
  RotateAPIKeyRequest,
27
28
  SignUpRequest,
28
29
  SignUpResponse,
29
- SnowflakeCredentials,
30
+ SnowflakeUserCredentials,
30
31
  Transformation,
31
32
  TransformationCreate,
32
33
  User,
@@ -41,7 +42,7 @@ class Client:
41
42
  self._base_url = (
42
43
  "https://api.cecil.earth" if env is None else f"https://{env}.cecil.earth"
43
44
  )
44
- self._snowflake_creds = None
45
+ self._snowflake_user_creds = None
45
46
 
46
47
  def create_aoi(self, name: str, geometry: Dict) -> AOI:
47
48
  # TODO: validate geometry
@@ -93,14 +94,19 @@ class Client:
93
94
  return [Transformation(**record) for record in res["records"]]
94
95
 
95
96
  def query(self, sql: str) -> pd.DataFrame:
96
- if self._snowflake_creds is None:
97
- res = self._get(url="/v0/data-access-credentials")
98
- self._snowflake_creds = SnowflakeCredentials(**res)
97
+ if self._snowflake_user_creds is None:
98
+ res = self._get(url="/v0/snowflake-user-credentials")
99
+ self._snowflake_user_creds = SnowflakeUserCredentials(**res)
100
+
101
+ private_key = serialization.load_pem_private_key(
102
+ self._snowflake_user_creds.private_key.get_secret_value().encode(),
103
+ password=None,
104
+ )
99
105
 
100
106
  with snowflake.connector.connect(
101
- account=self._snowflake_creds.account.get_secret_value(),
102
- user=self._snowflake_creds.user.get_secret_value(),
103
- password=self._snowflake_creds.password.get_secret_value(),
107
+ account=self._snowflake_user_creds.account.get_secret_value(),
108
+ user=self._snowflake_user_creds.user.get_secret_value(),
109
+ private_key=private_key,
104
110
  ) as conn:
105
111
  df = conn.cursor().execute(sql).fetch_pandas_all()
106
112
  df.columns = [x.lower() for x in df.columns]
cecil/models.py CHANGED
@@ -77,11 +77,11 @@ class TransformationCreate(BaseModel):
77
77
  spatial_resolution: float
78
78
 
79
79
 
80
- class SnowflakeCredentials(BaseModel):
80
+ class SnowflakeUserCredentials(BaseModel):
81
81
  model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
82
82
  account: SecretStr
83
83
  user: SecretStr
84
- password: SecretStr
84
+ private_key: SecretStr
85
85
 
86
86
 
87
87
  class User(BaseModel):
cecil/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.17"
1
+ __version__ = "0.0.18"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cecil
3
- Version: 0.0.17
3
+ Version: 0.0.18
4
4
  Summary: Python SDK for Cecil Earth
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE.txt
@@ -0,0 +1,9 @@
1
+ cecil/__init__.py,sha256=AEcRl73BDSAQe6W0d1PDD87IEcumARtREl7dCVa_YQY,86
2
+ cecil/client.py,sha256=S6j7jwDdp02eFB3c3IlQ2b6h3qaVb7UCUR7Dh_wr66o,7288
3
+ cecil/errors.py,sha256=ZNiSTYH2MgNZ7tNIgV07-Ge3KtmdncfzWiBi9yjURGs,1818
4
+ cecil/models.py,sha256=BjSJlcRBSuJjUoTHa4y-2i-9dIGct9giLvg7DQPgerQ,2841
5
+ cecil/version.py,sha256=qgKF-lRlzaBqf95e1sodHCZkSUCbz7ECKSeYHwXfAvI,23
6
+ cecil-0.0.18.dist-info/METADATA,sha256=vrVGp0w4-sX9iz5wwW1eEGLkdHK6ciqrpZ8-YjoRl_w,2659
7
+ cecil-0.0.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ cecil-0.0.18.dist-info/licenses/LICENSE.txt,sha256=mUexcmfYx3bG1VIzAdQTOf_NzStYw6-QkKVdUY_d4i4,1066
9
+ cecil-0.0.18.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- cecil/__init__.py,sha256=AEcRl73BDSAQe6W0d1PDD87IEcumARtREl7dCVa_YQY,86
2
- cecil/client.py,sha256=n8Ft-K1XLt430RCM6jUgBwWhwQlCJT8umyZp6RKpIyw,7054
3
- cecil/errors.py,sha256=ZNiSTYH2MgNZ7tNIgV07-Ge3KtmdncfzWiBi9yjURGs,1818
4
- cecil/models.py,sha256=0n5q7oUA7khdc5eB6C8aSW6Yx5LgyN_fA-GHb8y9Z7M,2834
5
- cecil/version.py,sha256=WlMBNrzKywm5RAbqEVgEgcG7Opc4cf3-wpAnO8PdoEI,23
6
- cecil-0.0.17.dist-info/METADATA,sha256=pK-PX-p6uyf-_MNbICW_ukGHnKzdnHiSFz5pFW3dOLw,2659
7
- cecil-0.0.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- cecil-0.0.17.dist-info/licenses/LICENSE.txt,sha256=mUexcmfYx3bG1VIzAdQTOf_NzStYw6-QkKVdUY_d4i4,1066
9
- cecil-0.0.17.dist-info/RECORD,,
File without changes