scrapely-python 0.1.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.
Files changed (43) hide show
  1. scrapely/__init__.py +246 -0
  2. scrapely/_browser_locations.py +5470 -0
  3. scrapely/actor.py +1836 -0
  4. scrapely/browser_configuration.py +146 -0
  5. scrapely/charging.py +1143 -0
  6. scrapely/charging_client.py +107 -0
  7. scrapely/configuration.py +375 -0
  8. scrapely/crypto/__init__.py +21 -0
  9. scrapely/crypto/_secrets.py +210 -0
  10. scrapely/errors.py +153 -0
  11. scrapely/events/__init__.py +57 -0
  12. scrapely/events/_types.py +194 -0
  13. scrapely/events/event_manager.py +292 -0
  14. scrapely/log.py +39 -0
  15. scrapely/patch_browser_pool.py +861 -0
  16. scrapely/pricing_types.py +172 -0
  17. scrapely/proxy_configuration.py +741 -0
  18. scrapely/py.typed +2 -0
  19. scrapely/request_loaders/__init__.py +5 -0
  20. scrapely/request_loaders/_scrapely_request_list.py +169 -0
  21. scrapely/storage/__init__.py +48 -0
  22. scrapely/storage/_file_system/__init__.py +9 -0
  23. scrapely/storage/_file_system/_key_value_store_client.py +155 -0
  24. scrapely/storage/_file_system/_storage_client.py +50 -0
  25. scrapely/storage/_metadata.py +138 -0
  26. scrapely/storage/api_client.py +350 -0
  27. scrapely/storage/client.py +618 -0
  28. scrapely/storage/patch_storage.py +257 -0
  29. scrapely/storage/scrapely_dataset_client.py +305 -0
  30. scrapely/storage/scrapely_kvs_client.py +220 -0
  31. scrapely/storage/scrapely_rq_client.py +496 -0
  32. scrapely/storage/scrapely_storage_client.py +192 -0
  33. scrapely/storage/smart_scrapely_storage_client.py +109 -0
  34. scrapely/storage/types.py +601 -0
  35. scrapely/storage/utils.py +38 -0
  36. scrapely/storage_clients/__init__.py +25 -0
  37. scrapely/storages/__init__.py +5 -0
  38. scrapely/types.py +269 -0
  39. scrapely/webhook.py +82 -0
  40. scrapely_python-0.1.0.dist-info/METADATA +83 -0
  41. scrapely_python-0.1.0.dist-info/RECORD +43 -0
  42. scrapely_python-0.1.0.dist-info/WHEEL +5 -0
  43. scrapely_python-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,172 @@
1
+ """
2
+ Pricing types for Scrapely Actors.
3
+
4
+ This module defines the pricing models and related types for Actors
5
+ on the Scrapely platform, following the Apify SDK pattern.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from datetime import datetime
11
+ from decimal import Decimal
12
+ from enum import Enum
13
+ from typing import Any, Dict, List, Optional, Union
14
+
15
+ from pydantic import BaseModel, ConfigDict, Field
16
+
17
+
18
+ class PricingModel(str, Enum):
19
+ """Pricing model types for Actors."""
20
+ FREE = 'FREE'
21
+ PRICE_PER_DATASET_ITEM = 'PRICE_PER_DATASET_ITEM'
22
+ PAY_PER_EVENT = 'PAY_PER_EVENT'
23
+
24
+
25
+ class BasePricingInfo(BaseModel):
26
+ """Base class for pricing information."""
27
+ model_config = ConfigDict(populate_by_name=True)
28
+
29
+ apify_margin_percentage: Optional[float] = Field(
30
+ default=None,
31
+ alias='apifyMarginPercentage',
32
+ description="Apify's margin on the price, as a percentage."
33
+ )
34
+ created_at: Optional[datetime] = Field(
35
+ default=None,
36
+ alias='createdAt',
37
+ description='Timestamp when this pricing info was created.'
38
+ )
39
+ started_at: Optional[datetime] = Field(
40
+ default=None,
41
+ alias='startedAt',
42
+ description='Timestamp when this pricing became effective.'
43
+ )
44
+
45
+
46
+ class FreeActorPricingInfo(BasePricingInfo):
47
+ """Pricing info for an Actor offered free of charge."""
48
+ pass
49
+
50
+
51
+ class FlatPricePerMonthActorPricingInfo(BasePricingInfo):
52
+ """Pricing info for an Actor billed at a flat monthly price."""
53
+ price_per_unit_usd: Optional[float] = Field(
54
+ default=None,
55
+ alias='pricePerUnitUsd',
56
+ description='Price per unit, in USD.'
57
+ )
58
+ trial_minutes: Optional[int] = Field(
59
+ default=None,
60
+ alias='trialMinutes',
61
+ description='Length of the free trial period, in minutes.'
62
+ )
63
+
64
+
65
+ class PricePerDatasetItemActorPricingInfo(BasePricingInfo):
66
+ """Pricing info for an Actor billed per dataset item produced."""
67
+ unit_name: Optional[str] = Field(
68
+ default=None,
69
+ alias='unitName',
70
+ description='Name of the billed unit.'
71
+ )
72
+
73
+
74
+ class PricingPerEvent(BaseModel):
75
+ """Pricing details for a single event type in pay-per-event model."""
76
+ model_config = ConfigDict(populate_by_name=True)
77
+
78
+ event_price_usd: Decimal = Field(
79
+ alias='eventPriceUsd',
80
+ description='Price per event in USD.'
81
+ )
82
+ event_description: Optional[str] = Field(
83
+ default=None,
84
+ alias='eventDescription',
85
+ description='Human-readable description of the event.'
86
+ )
87
+
88
+
89
+ class PayPerEventActorPricingInfo(BasePricingInfo):
90
+ """Pricing info for an Actor billed per charged event."""
91
+ pricing_per_event: Dict[str, PricingPerEvent] = Field(
92
+ default_factory=dict,
93
+ alias='pricingPerEvent',
94
+ description='The pay-per-event pricing details.'
95
+ )
96
+
97
+
98
+ # Union type for all pricing info types
99
+ ActorPricingInfo = Union[
100
+ FreeActorPricingInfo,
101
+ FlatPricePerMonthActorPricingInfo,
102
+ PricePerDatasetItemActorPricingInfo,
103
+ PayPerEventActorPricingInfo,
104
+ ]
105
+
106
+
107
+ class ActorChargeEvent(BaseModel):
108
+ """Definition of a single chargeable event in the pay-per-event pricing model."""
109
+ model_config = ConfigDict(populate_by_name=True)
110
+
111
+ event_description: Optional[str] = Field(
112
+ default=None,
113
+ alias='eventDescription',
114
+ description='Human-readable description of the event.'
115
+ )
116
+
117
+
118
+ class ChargeResult(BaseModel):
119
+ """Result of the ChargingManager.charge method."""
120
+ model_config = ConfigDict(populate_by_name=True)
121
+
122
+ chargeable_within_limit: Dict[str, Optional[int]] = Field(
123
+ alias='chargeableWithinLimit',
124
+ description='How many events of each known type can still be charged within the limit.'
125
+ )
126
+ charged_count: int = Field(
127
+ alias='chargedCount',
128
+ description='Total amount of charged events - may be lower than the requested amount.'
129
+ )
130
+ event_charge_limit_reached: bool = Field(
131
+ alias='eventChargeLimitReached',
132
+ description='If true, no more events of this type can be charged within the limit.'
133
+ )
134
+
135
+
136
+ class ActorPricingInfoResult(BaseModel):
137
+ """Result of the ChargingManager.get_pricing_info method."""
138
+ model_config = ConfigDict(populate_by_name=True, allow_inf_nan=True)
139
+
140
+ is_pay_per_event: bool = Field(
141
+ alias='isPayPerEvent',
142
+ description='A shortcut - true if the Actor runs with the pay-per-event pricing model.'
143
+ )
144
+ max_total_charge_usd: Union[Decimal, float] = Field(
145
+ alias='maxTotalChargeUsd',
146
+ description='A configured limit for the total charged amount (inf when uncapped).'
147
+ )
148
+ per_event_prices: Dict[str, Decimal] = Field(
149
+ default_factory=dict,
150
+ alias='perEventPrices',
151
+ description='Price of every known event type.'
152
+ )
153
+ pricing_model: Optional[PricingModel] = Field(
154
+ default=None,
155
+ alias='pricingModel',
156
+ description='The currently effective pricing model.'
157
+ )
158
+
159
+
160
+ __all__ = [
161
+ 'PricingModel',
162
+ 'BasePricingInfo',
163
+ 'FreeActorPricingInfo',
164
+ 'FlatPricePerMonthActorPricingInfo',
165
+ 'PricePerDatasetItemActorPricingInfo',
166
+ 'PayPerEventActorPricingInfo',
167
+ 'PricingPerEvent',
168
+ 'ActorPricingInfo',
169
+ 'ActorChargeEvent',
170
+ 'ChargeResult',
171
+ 'ActorPricingInfoResult',
172
+ ]