rapidata 2.17.1__py3-none-any.whl → 2.19.0__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 rapidata might be problematic. Click here for more details.

Files changed (38) hide show
  1. rapidata/__init__.py +2 -0
  2. rapidata/api_client/__init__.py +7 -5
  3. rapidata/api_client/api/order_api.py +3 -6
  4. rapidata/api_client/api/pipeline_api.py +665 -98
  5. rapidata/api_client/api/validation_set_api.py +6 -6
  6. rapidata/api_client/models/__init__.py +7 -5
  7. rapidata/api_client/models/add_user_response_result.py +3 -3
  8. rapidata/api_client/models/campaign_query_result.py +2 -2
  9. rapidata/api_client/models/campaign_status.py +2 -1
  10. rapidata/api_client/models/create_order_model_user_filters_inner.py +39 -9
  11. rapidata/api_client/models/get_simple_workflow_results_result.py +3 -3
  12. rapidata/api_client/models/get_validation_rapids_result.py +143 -0
  13. rapidata/api_client/models/get_validation_rapids_result_asset.py +174 -0
  14. rapidata/api_client/models/get_validation_rapids_result_paged_result.py +105 -0
  15. rapidata/api_client/models/get_validation_rapids_result_payload.py +252 -0
  16. rapidata/api_client/models/get_validation_rapids_result_truth.py +258 -0
  17. rapidata/api_client/models/not_user_filter_model.py +102 -0
  18. rapidata/api_client/models/or_user_filter_model.py +106 -0
  19. rapidata/api_client/models/query_validation_rapids_result.py +9 -9
  20. rapidata/api_client/rest.py +143 -169
  21. rapidata/api_client_README.md +9 -5
  22. rapidata/rapidata_client/__init__.py +2 -0
  23. rapidata/rapidata_client/filter/__init__.py +2 -0
  24. rapidata/rapidata_client/filter/not_filter.py +30 -0
  25. rapidata/rapidata_client/filter/or_filter.py +30 -0
  26. rapidata/rapidata_client/filter/rapidata_filters.py +6 -3
  27. rapidata/rapidata_client/order/rapidata_order.py +2 -2
  28. rapidata/rapidata_client/rapidata_client.py +27 -16
  29. rapidata/rapidata_client/selection/__init__.py +2 -0
  30. rapidata/rapidata_client/selection/static_selection.py +22 -0
  31. rapidata/rapidata_client/validation/validation_set_manager.py +1 -1
  32. rapidata/service/credential_manager.py +2 -2
  33. rapidata/service/openapi_service.py +56 -28
  34. {rapidata-2.17.1.dist-info → rapidata-2.19.0.dist-info}/METADATA +2 -1
  35. {rapidata-2.17.1.dist-info → rapidata-2.19.0.dist-info}/RECORD +37 -28
  36. rapidata/service/token_manager.py +0 -176
  37. {rapidata-2.17.1.dist-info → rapidata-2.19.0.dist-info}/LICENSE +0 -0
  38. {rapidata-2.17.1.dist-info → rapidata-2.19.0.dist-info}/WHEEL +0 -0
@@ -162,8 +162,10 @@ Class | Method | HTTP request | Description
162
162
  *OrderApi* | [**orders_public_get**](rapidata/api_client/docs/OrderApi.md#orders_public_get) | **GET** /orders/public | Retrieves orders that are public and can be cloned by any user.
163
163
  *PipelineApi* | [**pipeline_id_workflow_artifact_id_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_workflow_artifact_id_put) | **PUT** /pipeline/{id}/workflow/{artifactId} | Updates the workflow configuration for a pipeline.
164
164
  *PipelineApi* | [**pipeline_id_workflow_config_artifact_id_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_workflow_config_artifact_id_put) | **PUT** /pipeline/{id}/workflow-config/{artifactId} | Updates the workflow configuration for a pipeline.
165
+ *PipelineApi* | [**pipeline_id_workflow_config_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_id_workflow_config_put) | **PUT** /pipeline/{id}/workflow-config | Updates the workflow configuration for a pipeline.
165
166
  *PipelineApi* | [**pipeline_pipeline_id_campaign_artifact_id_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_pipeline_id_campaign_artifact_id_put) | **PUT** /pipeline/{pipelineId}/campaign/{artifactId} | Updates a specific campaign for a pipeline.
166
167
  *PipelineApi* | [**pipeline_pipeline_id_campaign_post**](rapidata/api_client/docs/PipelineApi.md#pipeline_pipeline_id_campaign_post) | **POST** /pipeline/{pipelineId}/campaign | Adds a campaign to a pipeline.
168
+ *PipelineApi* | [**pipeline_pipeline_id_campaign_put**](rapidata/api_client/docs/PipelineApi.md#pipeline_pipeline_id_campaign_put) | **PUT** /pipeline/{pipelineId}/campaign | Updates a specific campaign for a pipeline.
167
169
  *PipelineApi* | [**pipeline_pipeline_id_get**](rapidata/api_client/docs/PipelineApi.md#pipeline_pipeline_id_get) | **GET** /pipeline/{pipelineId} | Gets a pipeline by its id.
168
170
  *PipelineApi* | [**pipeline_pipeline_id_preliminary_download_post**](rapidata/api_client/docs/PipelineApi.md#pipeline_pipeline_id_preliminary_download_post) | **POST** /pipeline/{pipelineId}/preliminary-download | Initiates a preliminary download of the pipeline.
169
171
  *PipelineApi* | [**pipeline_preliminary_download_preliminary_download_id_get**](rapidata/api_client/docs/PipelineApi.md#pipeline_preliminary_download_preliminary_download_id_get) | **GET** /pipeline/preliminary-download/{preliminaryDownloadId} | Gets the preliminary download.
@@ -223,7 +225,6 @@ Class | Method | HTTP request | Description
223
225
  - [AddCampaignArtifactResult](rapidata/api_client/docs/AddCampaignArtifactResult.md)
224
226
  - [AddCampaignModel](rapidata/api_client/docs/AddCampaignModel.md)
225
227
  - [AddUserResponseResult](rapidata/api_client/docs/AddUserResponseResult.md)
226
- - [AddUserResponseResultValidationTruth](rapidata/api_client/docs/AddUserResponseResultValidationTruth.md)
227
228
  - [AddValidationRapidModel](rapidata/api_client/docs/AddValidationRapidModel.md)
228
229
  - [AddValidationRapidModelPayload](rapidata/api_client/docs/AddValidationRapidModelPayload.md)
229
230
  - [AddValidationRapidModelTruth](rapidata/api_client/docs/AddValidationRapidModelTruth.md)
@@ -353,8 +354,11 @@ Class | Method | HTTP request | Description
353
354
  - [GetSimpleWorkflowResultsModel](rapidata/api_client/docs/GetSimpleWorkflowResultsModel.md)
354
355
  - [GetSimpleWorkflowResultsResult](rapidata/api_client/docs/GetSimpleWorkflowResultsResult.md)
355
356
  - [GetSimpleWorkflowResultsResultPagedResult](rapidata/api_client/docs/GetSimpleWorkflowResultsResultPagedResult.md)
356
- - [GetValidationRapidsQuery](rapidata/api_client/docs/GetValidationRapidsQuery.md)
357
- - [GetValidationRapidsQueryPagedResult](rapidata/api_client/docs/GetValidationRapidsQueryPagedResult.md)
357
+ - [GetValidationRapidsResult](rapidata/api_client/docs/GetValidationRapidsResult.md)
358
+ - [GetValidationRapidsResultAsset](rapidata/api_client/docs/GetValidationRapidsResultAsset.md)
359
+ - [GetValidationRapidsResultPagedResult](rapidata/api_client/docs/GetValidationRapidsResultPagedResult.md)
360
+ - [GetValidationRapidsResultPayload](rapidata/api_client/docs/GetValidationRapidsResultPayload.md)
361
+ - [GetValidationRapidsResultTruth](rapidata/api_client/docs/GetValidationRapidsResultTruth.md)
358
362
  - [GetValidationSetByIdResult](rapidata/api_client/docs/GetValidationSetByIdResult.md)
359
363
  - [GetWorkflowByIdResult](rapidata/api_client/docs/GetWorkflowByIdResult.md)
360
364
  - [GetWorkflowByIdResultWorkflow](rapidata/api_client/docs/GetWorkflowByIdResultWorkflow.md)
@@ -395,10 +399,12 @@ Class | Method | HTTP request | Description
395
399
  - [NewUserFilterModel](rapidata/api_client/docs/NewUserFilterModel.md)
396
400
  - [NewsletterModel](rapidata/api_client/docs/NewsletterModel.md)
397
401
  - [NotAvailableYetResult](rapidata/api_client/docs/NotAvailableYetResult.md)
402
+ - [NotUserFilterModel](rapidata/api_client/docs/NotUserFilterModel.md)
398
403
  - [NullAssetModel](rapidata/api_client/docs/NullAssetModel.md)
399
404
  - [OnlinePairMakerConfig](rapidata/api_client/docs/OnlinePairMakerConfig.md)
400
405
  - [OnlinePairMakerConfigModel](rapidata/api_client/docs/OnlinePairMakerConfigModel.md)
401
406
  - [OnlinePairMakerInformation](rapidata/api_client/docs/OnlinePairMakerInformation.md)
407
+ - [OrUserFilterModel](rapidata/api_client/docs/OrUserFilterModel.md)
402
408
  - [OrderModel](rapidata/api_client/docs/OrderModel.md)
403
409
  - [OrderModelPagedResult](rapidata/api_client/docs/OrderModelPagedResult.md)
404
410
  - [OrderState](rapidata/api_client/docs/OrderState.md)
@@ -421,9 +427,7 @@ Class | Method | HTTP request | Description
421
427
  - [PublicTextMetadataInput](rapidata/api_client/docs/PublicTextMetadataInput.md)
422
428
  - [QueryModel](rapidata/api_client/docs/QueryModel.md)
423
429
  - [QueryValidationRapidsResult](rapidata/api_client/docs/QueryValidationRapidsResult.md)
424
- - [QueryValidationRapidsResultAsset](rapidata/api_client/docs/QueryValidationRapidsResultAsset.md)
425
430
  - [QueryValidationRapidsResultPagedResult](rapidata/api_client/docs/QueryValidationRapidsResultPagedResult.md)
426
- - [QueryValidationRapidsResultPayload](rapidata/api_client/docs/QueryValidationRapidsResultPayload.md)
427
431
  - [QueryWorkflowsModel](rapidata/api_client/docs/QueryWorkflowsModel.md)
428
432
  - [RapidIssue](rapidata/api_client/docs/RapidIssue.md)
429
433
  - [RapidResponse](rapidata/api_client/docs/RapidResponse.md)
@@ -40,6 +40,8 @@ from .filter import (
40
40
  CustomFilter,
41
41
  AgeGroup,
42
42
  Gender,
43
+ NotFilter,
44
+ OrFilter,
43
45
  )
44
46
 
45
47
  from .validation import Box
@@ -6,3 +6,5 @@ from .gender_filter import GenderFilter, Gender
6
6
  from .language_filter import LanguageFilter
7
7
  from .user_score_filter import UserScoreFilter
8
8
  from .custom_filter import CustomFilter
9
+ from .not_filter import NotFilter
10
+ from .or_filter import OrFilter
@@ -0,0 +1,30 @@
1
+ from typing import Any
2
+ from rapidata.rapidata_client.filter._base_filter import RapidataFilter
3
+ from rapidata.api_client.models.not_user_filter_model import NotUserFilterModel
4
+ from rapidata.api_client.models.create_order_model_user_filters_inner import CreateOrderModelUserFiltersInner
5
+
6
+
7
+ class NotFilter(RapidataFilter):
8
+ """A filter that negates another filter's condition.
9
+ This class implements a logical NOT operation on a given filter, inverting its results.
10
+
11
+ Args:
12
+ filter (RapidataFilter): The filter whose condition should be negated.
13
+
14
+ Example:
15
+ ```python
16
+ from rapidata import NotFilter, LanguageFilter
17
+
18
+ NotFilter(LanguageFilter(["en"]))
19
+ ```
20
+
21
+ This will limit the order to be shown to only people who have their phone set to a language other than English.
22
+ """
23
+ def __init__(self, filter: RapidataFilter):
24
+ if not isinstance(filter, RapidataFilter):
25
+ raise ValueError("Filter must be a RapidataFilter object")
26
+
27
+ self.filter = filter
28
+
29
+ def _to_model(self):
30
+ return NotUserFilterModel(_t="NotFilter", filter=CreateOrderModelUserFiltersInner(self.filter._to_model()))
@@ -0,0 +1,30 @@
1
+ from typing import Any
2
+ from rapidata.rapidata_client.filter._base_filter import RapidataFilter
3
+ from rapidata.api_client.models.or_user_filter_model import OrUserFilterModel
4
+ from rapidata.api_client.models.create_order_model_user_filters_inner import CreateOrderModelUserFiltersInner
5
+
6
+
7
+ class OrFilter(RapidataFilter):
8
+ """A filter that combines multiple filters with a logical OR operation.
9
+ This class implements a logical OR operation on a list of filters, where the condition is met if any of the filters' conditions are met.
10
+
11
+ Args:
12
+ filters (list[RapidataFilter]): A list of filters to be combined with OR.
13
+
14
+ Example:
15
+ ```python
16
+ from rapidata import OrFilter, LanguageFilter, CountryFilter
17
+
18
+ OrFilter([LanguageFilter(["en"]), CountryFilter(["US"])])
19
+ ```
20
+
21
+ This will match users who either have their phone set to English OR are located in the United States.
22
+ """
23
+ def __init__(self, filters: list[RapidataFilter]):
24
+ if not all(isinstance(filter, RapidataFilter) for filter in filters):
25
+ raise ValueError("Filters must be a RapidataFilter object")
26
+
27
+ self.filters = filters
28
+
29
+ def _to_model(self):
30
+ return OrUserFilterModel(_t="OrFilter", filters=[CreateOrderModelUserFiltersInner(filter._to_model()) for filter in self.filters])
@@ -5,7 +5,8 @@ from rapidata.rapidata_client.filter import (
5
5
  GenderFilter,
6
6
  LanguageFilter,
7
7
  UserScoreFilter,
8
- CustomFilter)
8
+ NotFilter,
9
+ OrFilter)
9
10
 
10
11
  class RapidataFilters:
11
12
  """RapidataFilters Classes
@@ -24,7 +25,8 @@ class RapidataFilters:
24
25
  country (CountryFilter): The CountryFilter instance.
25
26
  gender (GenderFilter): The GenderFilter instance.
26
27
  language (LanguageFilter): The LanguageFilter instance.
27
- custom_filter (CustomFilter): The CustomFilter instance.
28
+ not_filter (NotFilter): The NotFilter instance.
29
+ or_filter (OrFilter): The OrFilter instance.
28
30
 
29
31
  Example:
30
32
  ```python
@@ -40,4 +42,5 @@ class RapidataFilters:
40
42
  country = CountryFilter
41
43
  gender = GenderFilter
42
44
  language = LanguageFilter
43
- custom_filter = CustomFilter
45
+ not_filter = NotFilter
46
+ or_filter = OrFilter
@@ -51,7 +51,7 @@ class RapidataOrder:
51
51
  """Runs the order to start collecting responses."""
52
52
  self.__openapi_service.order_api.order_submit_post(self.order_id)
53
53
  if print_link:
54
- print(f"Order '{self.name}' is now viewable under: https://app.{self.__openapi_service.enviroment}/order/detail/{self.order_id}")
54
+ print(f"Order '{self.name}' is now viewable under: https://app.{self.__openapi_service.environment}/order/detail/{self.order_id}")
55
55
  return self
56
56
 
57
57
  def pause(self) -> None:
@@ -167,7 +167,7 @@ class RapidataOrder:
167
167
  Exception: If the order is not in processing state.
168
168
  """
169
169
  campaign_id = self.__get_campaign_id()
170
- auth_url = f"https://app.{self.__openapi_service.enviroment}/order/detail/{self.order_id}/preview?campaignId={campaign_id}"
170
+ auth_url = f"https://app.{self.__openapi_service.environment}/order/detail/{self.order_id}/preview?campaignId={campaign_id}"
171
171
  could_open_browser = webbrowser.open(auth_url)
172
172
  if not could_open_browser:
173
173
  encoded_url = urllib.parse.quote(auth_url, safe="%/:=&?~#+!$,;'@()*[]")
@@ -2,28 +2,37 @@ from rapidata.service.openapi_service import OpenAPIService
2
2
 
3
3
  from rapidata.rapidata_client.order.rapidata_order_manager import RapidataOrderManager
4
4
 
5
- from rapidata.rapidata_client.validation.validation_set_manager import ValidationSetManager
5
+ from rapidata.rapidata_client.validation.validation_set_manager import (
6
+ ValidationSetManager,
7
+ )
6
8
 
7
9
  from rapidata.rapidata_client.demographic.demographic_manager import DemographicManager
8
10
 
11
+
9
12
  class RapidataClient:
10
13
  """The Rapidata client is the main entry point for interacting with the Rapidata API. It allows you to create orders and validation sets."""
11
-
14
+
12
15
  def __init__(
13
- self,
14
- client_id: str | None = None,
15
- client_secret: str | None = None,
16
- enviroment: str = "rapidata.ai",
17
- oauth_scope: str = "openid",
18
- cert_path: str | None = None,
16
+ self,
17
+ client_id: str | None = None,
18
+ client_secret: str | None = None,
19
+ environment: str = "rapidata.ai",
20
+ oauth_scope: str = "openid",
21
+ cert_path: str | None = None,
22
+ token: dict | None = None,
23
+ leeway: int = 60
19
24
  ):
20
- """Initialize the RapidataClient. If both the client_id and client_secret are None, it will try using your credentials under "~/.config/rapidata/credentials.json".
21
- If this is not successful, it will open a browser windown and ask you to log in, then save your new credentials in said json file.
25
+ """Initialize the RapidataClient. If both the client_id and client_secret are None, it will try using your credentials under "~/.config/rapidata/credentials.json".
26
+ If this is not successful, it will open a browser window and ask you to log in, then save your new credentials in said json file.
22
27
 
23
28
  Args:
24
29
  client_id (str): The client ID for authentication.
25
30
  client_secret (str): The client secret for authentication.
26
- enviroment (str, optional): The API endpoint.
31
+ environment (str, optional): The API endpoint.
32
+ oauth_scope (str, optional): The scopes to use for authentication. In general this does not need to be changed.
33
+ cert_path (str, optional): An optional path to a certificate file useful for development.
34
+ token (dict, optional): If you already have a token that the client should use for authentication. Important, if set, this needs to be the complete token object containing the access token, token type and expiration time.
35
+ leeway (int, optional): An optional leeway to use to determine if a token is expired. Defaults to 60 seconds.
27
36
 
28
37
  Attributes:
29
38
  order (RapidataOrderManager): The RapidataOrderManager instance.
@@ -32,17 +41,19 @@ class RapidataClient:
32
41
  self._openapi_service = OpenAPIService(
33
42
  client_id=client_id,
34
43
  client_secret=client_secret,
35
- enviroment=enviroment,
44
+ environment=environment,
36
45
  oauth_scope=oauth_scope,
37
- cert_path=cert_path
46
+ cert_path=cert_path,
47
+ token=token,
48
+ leeway=leeway,
38
49
  )
39
-
50
+
40
51
  self.order = RapidataOrderManager(openapi_service=self._openapi_service)
41
-
52
+
42
53
  self.validation = ValidationSetManager(openapi_service=self._openapi_service)
43
54
 
44
55
  self._demographic = DemographicManager(openapi_service=self._openapi_service)
45
56
 
46
57
  def reset_credentials(self):
47
- """Reset the credentials saved in the configuration file for the current enviroment."""
58
+ """Reset the credentials saved in the configuration file for the current environment."""
48
59
  self._openapi_service.reset_credentials()
@@ -5,3 +5,5 @@ from .validation_selection import ValidationSelection
5
5
  from .conditional_validation_selection import ConditionalValidationSelection
6
6
  from .capped_selection import CappedSelection
7
7
  from .shuffling_selection import ShufflingSelection
8
+ from .ab_test_selection import AbTestSelection
9
+ from .static_selection import StaticSelection
@@ -0,0 +1,22 @@
1
+
2
+ from rapidata.api_client.models.static_selection import StaticSelection as StaticSelectionModel
3
+ from rapidata.rapidata_client.selection._base_selection import RapidataSelection
4
+
5
+ class StaticSelection(RapidataSelection):
6
+ """StaticSelection Class
7
+
8
+ Given a list of RapidIds, theses specific rapids will be shown in order for every session.
9
+
10
+ Args:
11
+ selections (list[str]): List of rapid ids to show.
12
+ """
13
+
14
+ def __init__(self, rapid_ids: list[str]):
15
+ self.rapid_ids = rapid_ids
16
+
17
+ def _to_model(self) -> StaticSelectionModel:
18
+ return StaticSelectionModel(
19
+ _t="StaticSelection",
20
+ rapidIds=self.rapid_ids
21
+ )
22
+
@@ -468,7 +468,7 @@ class ValidationSetManager:
468
468
  if print_confirmation:
469
469
  print()
470
470
  print(f"Validation set '{name}' created with ID {validation_set_id}\n",
471
- f"Now viewable under: https://app.{self.__openapi_service.enviroment}/validation-set/detail/{validation_set_id}",
471
+ f"Now viewable under: https://app.{self.__openapi_service.environment}/validation-set/detail/{validation_set_id}",
472
472
  sep="")
473
473
 
474
474
  if dimensions:
@@ -133,9 +133,9 @@ class CredentialManager:
133
133
  return credential
134
134
 
135
135
  return self._create_new_credentials()
136
-
136
+
137
137
  def reset_credentials(self) -> None:
138
- """Reset the stored credentials for current enviroment."""
138
+ """Reset the stored credentials for current environment."""
139
139
  credentials = self._read_credentials()
140
140
  if self.endpoint in credentials:
141
141
  del credentials[self.endpoint]
@@ -1,3 +1,6 @@
1
+ import subprocess
2
+ from importlib.metadata import version, PackageNotFoundError
3
+
1
4
  from rapidata.api_client.api.campaign_api import CampaignApi
2
5
  from rapidata.api_client.api.dataset_api import DatasetApi
3
6
  from rapidata.api_client.api.order_api import OrderApi
@@ -7,31 +10,31 @@ from rapidata.api_client.api.validation_api import ValidationApi
7
10
  from rapidata.api_client.api.workflow_api import WorkflowApi
8
11
  from rapidata.api_client.api_client import ApiClient
9
12
  from rapidata.api_client.configuration import Configuration
10
- from rapidata.service.token_manager import TokenManager, TokenInfo
11
13
  from rapidata.service.credential_manager import CredentialManager
12
14
 
13
- from importlib.metadata import version, PackageNotFoundError
14
-
15
15
 
16
16
  class OpenAPIService:
17
17
  def __init__(
18
- self,
19
- client_id: str | None,
20
- client_secret: str | None,
21
- enviroment: str,
22
- oauth_scope: str,
23
- cert_path: str | None = None,
18
+ self,
19
+ client_id: str | None,
20
+ client_secret: str | None,
21
+ environment: str,
22
+ oauth_scope: str,
23
+ cert_path: str | None = None,
24
+ token: dict | None = None,
25
+ leeway: int = 60,
24
26
  ):
25
- self.enviroment = enviroment
26
- endpoint = f"https://api.{enviroment}"
27
- self._token_url = f"https://auth.{enviroment}"
28
- token_manager = TokenManager(
29
- client_id=client_id,
30
- client_secret=client_secret,
31
- endpoint=self._token_url,
32
- oauth_scope=oauth_scope,
33
- cert_path=cert_path,
27
+ self.environment = environment
28
+ endpoint = f"https://api.{environment}"
29
+ auth_endpoint = f"https://auth.{environment}"
30
+
31
+ if environment == "rapidata.dev" and not cert_path:
32
+ cert_path = _get_local_certificate()
33
+
34
+ self.credential_manager = CredentialManager(
35
+ endpoint=auth_endpoint, cert_path=cert_path
34
36
  )
37
+
35
38
  client_configuration = Configuration(host=endpoint, ssl_ca_cert=cert_path)
36
39
  self.api_client = ApiClient(
37
40
  configuration=client_configuration,
@@ -39,16 +42,32 @@ class OpenAPIService:
39
42
  header_value=f"RapidataPythonSDK/{self._get_rapidata_package_version()}",
40
43
  )
41
44
 
42
- self.api_client.configuration.api_key["bearer"] = (
43
- f"Bearer {token_manager.fetch_token().access_token}"
45
+ if token:
46
+ self.api_client.rest_client.setup_oauth_with_token(
47
+ token=token,
48
+ token_endpoint=f"{auth_endpoint}/connect/token",
49
+ client_id=client_id,
50
+ client_secret=client_secret,
51
+ leeway=leeway,
52
+ )
53
+ return
54
+
55
+ if not client_id or not client_secret:
56
+ credentials = self.credential_manager.get_client_credentials()
57
+ if not credentials:
58
+ raise ValueError("Failed to fetch client credentials")
59
+ client_id = credentials.client_id
60
+ client_secret = credentials.client_secret
61
+
62
+ self.api_client.rest_client.setup_oauth_client_credentials(
63
+ client_id=client_id,
64
+ client_secret=client_secret,
65
+ token_endpoint=f"{auth_endpoint}/connect/token",
66
+ scope=oauth_scope,
44
67
  )
45
68
 
46
- self._cert_path = cert_path
47
-
48
- token_manager.start_token_refresh(token_callback=self._set_token)
49
-
50
69
  def reset_credentials(self):
51
- CredentialManager(endpoint=self._token_url, cert_path=self._cert_path).reset_credentials()
70
+ self.credential_manager.reset_credentials()
52
71
 
53
72
  @property
54
73
  def order_api(self) -> OrderApi:
@@ -78,9 +97,6 @@ class OpenAPIService:
78
97
  def workflow_api(self) -> WorkflowApi:
79
98
  return WorkflowApi(self.api_client)
80
99
 
81
- def _set_token(self, token: TokenInfo):
82
- self.api_client.configuration.api_key["bearer"] = f"Bearer {token.access_token}"
83
-
84
100
  def _get_rapidata_package_version(self):
85
101
  """
86
102
  Returns the version of the currently installed rapidata package.
@@ -93,3 +109,15 @@ class OpenAPIService:
93
109
  return version("rapidata")
94
110
  except PackageNotFoundError:
95
111
  return None
112
+
113
+
114
+ def _get_local_certificate() -> str | None:
115
+ result = subprocess.run(["mkcert", "-CAROOT"], capture_output=True)
116
+ if result.returncode != 0:
117
+ return None
118
+
119
+ output = result.stdout.decode("utf-8").strip()
120
+ if not output:
121
+ return None
122
+
123
+ return f"{output}/rootCA.pem"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rapidata
3
- Version: 2.17.1
3
+ Version: 2.19.0
4
4
  Summary: Rapidata package containing the Rapidata Python Client to interact with the Rapidata Web API in an easy way.
5
5
  License: Apache-2.0
6
6
  Author: Rapidata AG
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
+ Requires-Dist: authlib (>=1.5.1,<2.0.0)
15
16
  Requires-Dist: colorama (==0.4.6)
16
17
  Requires-Dist: deprecated (>=1.2.14,<2.0.0)
17
18
  Requires-Dist: pandas (>=2.2.3,<3.0.0)