cecil 0.0.17__py3-none-any.whl → 0.0.19__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,
@@ -20,13 +21,14 @@ from .models import (
20
21
  DataRequest,
21
22
  DataRequestCreate,
22
23
  OrganisationCreate,
24
+ OrganisationSettings,
23
25
  RecoverAPIKey,
24
26
  RecoverAPIKeyRequest,
25
27
  RotateAPIKey,
26
28
  RotateAPIKeyRequest,
27
29
  SignUpRequest,
28
30
  SignUpResponse,
29
- SnowflakeCredentials,
31
+ SnowflakeUserCredentials,
30
32
  Transformation,
31
33
  TransformationCreate,
32
34
  User,
@@ -41,7 +43,7 @@ class Client:
41
43
  self._base_url = (
42
44
  "https://api.cecil.earth" if env is None else f"https://{env}.cecil.earth"
43
45
  )
44
- self._snowflake_creds = None
46
+ self._snowflake_user_creds = None
45
47
 
46
48
  def create_aoi(self, name: str, geometry: Dict) -> AOI:
47
49
  # TODO: validate geometry
@@ -93,14 +95,19 @@ class Client:
93
95
  return [Transformation(**record) for record in res["records"]]
94
96
 
95
97
  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)
98
+ if self._snowflake_user_creds is None:
99
+ res = self._get(url="/v0/snowflake-user-credentials")
100
+ self._snowflake_user_creds = SnowflakeUserCredentials(**res)
101
+
102
+ private_key = serialization.load_pem_private_key(
103
+ self._snowflake_user_creds.private_key.get_secret_value().encode(),
104
+ password=None,
105
+ )
99
106
 
100
107
  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(),
108
+ account=self._snowflake_user_creds.account.get_secret_value(),
109
+ user=self._snowflake_user_creds.user.get_secret_value(),
110
+ private_key=private_key,
104
111
  ) as conn:
105
112
  df = conn.cursor().execute(sql).fetch_pandas_all()
106
113
  df.columns = [x.lower() for x in df.columns]
@@ -154,6 +161,23 @@ class Client:
154
161
  res = self._get(url="/v0/users")
155
162
  return [User(**record) for record in res["records"]]
156
163
 
164
+ def get_organisation_settings(self) -> OrganisationSettings:
165
+ res = self._get(url="/v0/organisation/settings")
166
+ return OrganisationSettings(**res)
167
+
168
+ def update_organisation_settings(
169
+ self,
170
+ *,
171
+ monthly_data_request_limit,
172
+ ) -> OrganisationSettings:
173
+ res = self._post(
174
+ url="/v0/organisation/settings",
175
+ model=OrganisationSettings(
176
+ monthly_data_request_limit=monthly_data_request_limit,
177
+ ),
178
+ )
179
+ return OrganisationSettings(**res)
180
+
157
181
  def _request(self, method: str, url: str, skip_auth=False, **kwargs) -> Dict:
158
182
 
159
183
  if skip_auth is False:
cecil/models.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import datetime
2
- from typing import Dict
2
+ from typing import Dict, Optional
3
3
 
4
4
  from pydantic import BaseModel, ConfigDict, SecretStr
5
5
  from pydantic.alias_generators import to_camel
@@ -41,6 +41,11 @@ class OrganisationCreate(BaseModel):
41
41
  name: str
42
42
 
43
43
 
44
+ class OrganisationSettings(BaseModel):
45
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
46
+ monthly_data_request_limit: Optional[int] = None
47
+
48
+
44
49
  class RecoverAPIKey(BaseModel):
45
50
  model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
46
51
  message: str
@@ -77,11 +82,11 @@ class TransformationCreate(BaseModel):
77
82
  spatial_resolution: float
78
83
 
79
84
 
80
- class SnowflakeCredentials(BaseModel):
85
+ class SnowflakeUserCredentials(BaseModel):
81
86
  model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
82
87
  account: SecretStr
83
88
  user: SecretStr
84
- password: SecretStr
89
+ private_key: SecretStr
85
90
 
86
91
 
87
92
  class User(BaseModel):
cecil/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.17"
1
+ __version__ = "0.0.19"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cecil
3
- Version: 0.0.17
3
+ Version: 0.0.19
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=XYfXnF2eydWIU0Gla4R4VEImlNoZP8t47-A2f4ym3B8,7861
3
+ cecil/errors.py,sha256=ZNiSTYH2MgNZ7tNIgV07-Ge3KtmdncfzWiBi9yjURGs,1818
4
+ cecil/models.py,sha256=7J-qnJWoPH_u9JQPWrGLOpAJU0uVD-FstPMF95KMuTk,3024
5
+ cecil/version.py,sha256=AixLlU6Em9Z_zs4l1lTxAHg1b8pa8z3BTNKIHDkjBmo,23
6
+ cecil-0.0.19.dist-info/METADATA,sha256=8o9ZKdTU_HSOdBtZADjHEXtTI6xZKZg8JKgxM_cyrbs,2659
7
+ cecil-0.0.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ cecil-0.0.19.dist-info/licenses/LICENSE.txt,sha256=mUexcmfYx3bG1VIzAdQTOf_NzStYw6-QkKVdUY_d4i4,1066
9
+ cecil-0.0.19.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