cloudnet-api-client 0.1.0__tar.gz → 0.1.1__tar.gz

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.
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.1.1 – 2025-03-27
9
+
10
+ - Add `updated_at_from` and `updated_at_to` parameters
11
+
8
12
  ## 0.1.0 – 2025-03-27
9
13
 
10
14
  - Initial release
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudnet-api-client
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Cloudnet API client
5
5
  Author-email: Simo Tukiainen <simo.tukiainen@fmi.fi>
6
6
  License-File: LICENSE
@@ -27,7 +27,13 @@ Description-Content-Type: text/markdown
27
27
 
28
28
  # cloudnet-api-client
29
29
 
30
- Official Python package for using Cloudnet API
30
+ Official Python client for the [Cloudnet data portal API](https://docs.cloudnet.fmi.fi/api/data-portal.html).
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ python3 -m pip install cloudnet-api-client
36
+ ```
31
37
 
32
38
  ## Quickstart
33
39
 
@@ -40,10 +46,10 @@ sites = client.sites(type="cloudnet")
40
46
  products = client.products()
41
47
 
42
48
  metadata = client.metadata("hyytiala", "2021-01-01", product=["mwr", "radar"])
43
- cac.download(metadata, "data")
49
+ cac.download(metadata, "data/")
44
50
 
45
- raw_metadata = client.metadata("hyytiala", "2021-01-01")
46
- cac.download(raw_metadata, "data_raw")
51
+ raw_metadata = client.raw_metadata("granada", date="2024-01", instrument_id="parsivel")
52
+ cac.download(raw_metadata, "data_raw/")
47
53
  ```
48
54
 
49
55
  ## Documentation
@@ -54,16 +60,18 @@ Fetch product and raw file metadata from the Cloudnet data portal.
54
60
 
55
61
  Parameters:
56
62
 
57
- | name | type | default | example |
58
- | -------------- | ------------------------ | ------- | ---------------------------------------------------- |
59
- | site_id | `str` | | "hyytiala" |
60
- | date | `str` or `datetime.date` | `None` | "2024-01-01" |
61
- | date_from | `str` or `datetime.date` | `None` | "2025-01-01" |
62
- | date_to | `str` or `datetime.date` | `None` | "2025-01-01" |
63
- | instrument_id | `str` or `[str]` | `None` | "rpg-fmcw-94" |
64
- | instrument_pid | `str` or `[str]` | `None` | "https://hdl.handle.net/21.12132/3.191564170f8a4686" |
65
- | product\* | `str` or `[str]` | `None` | "classification" |
66
- | show_legacy\* | `bool` | `False` | |
63
+ | name | type | default | example |
64
+ | --------------- | ------------------------ | ------- | ---------------------------------------------------- |
65
+ | site_id | `str` | | "hyytiala" |
66
+ | date | `str` or `datetime.date` | `None` | "2024-01-01" |
67
+ | date_from | `str` or `datetime.date` | `None` | "2025-01-01" |
68
+ | date_to | `str` or `datetime.date` | `None` | "2025-01-01" |
69
+ | updated_at_from | `str` or `datetime.date` | `None` | "2025-01-01" |
70
+ | updated_at_to | `str` or `datetime.date` | `None` | "2025-01-01" |
71
+ | instrument_id | `str` or `[str]` | `None` | "rpg-fmcw-94" |
72
+ | instrument_pid | `str` or `[str]` | `None` | "https://hdl.handle.net/21.12132/3.191564170f8a4686" |
73
+ | product\* | `str` or `[str]` | `None` | "classification" |
74
+ | show_legacy\* | `bool` | `False` | |
67
75
 
68
76
  \* = only in `metadata()`
69
77
 
@@ -76,7 +84,8 @@ The `date` parameter supports:
76
84
  - "YYYY" — the entire year
77
85
  - Or directly as `datetime.date` object
78
86
 
79
- The `date_from` and `date_to` parameters should be "YYYY-MM-DD" or `datetime.date`. If `date` is defined, `date_from` and `date_to` have no effect.
87
+ The `date_from`, `date_to`, `updated_at_from` and `updated_at_to` parameters
88
+ should be of form "YYYY-MM-DD" or `datetime.date`. Note that, if `date` is defined, `date_from` and `date_to` have no effect.
80
89
 
81
90
  **Return value**
82
91
 
@@ -98,16 +107,36 @@ Parameters:
98
107
  | include_tag_subset | `{str}` | `None` |
99
108
  | exclude_tag_subset | `{str}` | `None` |
100
109
 
110
+ ### `APIClient().sites()` &rarr; `[Site]`
111
+
112
+ Fetch cloudnet sites.
113
+
114
+ Parameters:
115
+
116
+ | name | type | Choices | default |
117
+ | ---- | ---------------- | ----------------------------------------- | ------- |
118
+ | type | `str` or `[str]` | "cloudnet", "campaign", "model", "hidden" | `None` |
119
+
120
+ ### `APIClient().products()` &rarr; `[Product]`
121
+
122
+ Fetch cloudnet products.
123
+
124
+ Parameters:
125
+
126
+ | name | type | Choices | default |
127
+ | ---- | ---------------- | ----------------------------------------- | ------- |
128
+ | type | `str` or `[str]` | "instrument", "geophysical", "evaluation" | `None` |
129
+
101
130
  ### `cloudnet_api_client.download([Metadata])`
102
131
 
103
- Function to download files from fetched metadata.
132
+ Download files from the fetched metadata.
104
133
 
105
134
  Parameters:
106
135
 
107
136
  | name | type | default |
108
137
  | ----------------- | -------------------------------------- | ------- |
109
138
  | metadata | `[RawMetadata]` or `[ProductMetadata]` | |
110
- | output_directory | `PathLike` | |
139
+ | output_directory | `PathLike` or `str` | |
111
140
  | concurrency_limit | `int` | 5 |
112
141
 
113
142
  ## License
@@ -0,0 +1,119 @@
1
+ [![CI](https://github.com/actris-cloudnet/cloudnet-api-client/actions/workflows/test.yml/badge.svg)](https://github.com/actris-cloudnet/cloudnet-api-client/actions/workflows/test.yml)
2
+
3
+ # cloudnet-api-client
4
+
5
+ Official Python client for the [Cloudnet data portal API](https://docs.cloudnet.fmi.fi/api/data-portal.html).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ python3 -m pip install cloudnet-api-client
11
+ ```
12
+
13
+ ## Quickstart
14
+
15
+ ```python
16
+ import cloudnet_api_client as cac
17
+
18
+ client = cac.APIClient()
19
+
20
+ sites = client.sites(type="cloudnet")
21
+ products = client.products()
22
+
23
+ metadata = client.metadata("hyytiala", "2021-01-01", product=["mwr", "radar"])
24
+ cac.download(metadata, "data/")
25
+
26
+ raw_metadata = client.raw_metadata("granada", date="2024-01", instrument_id="parsivel")
27
+ cac.download(raw_metadata, "data_raw/")
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ ### `APIClient().metadata()` and `raw_metadata()` &rarr; `[Metadata]`
33
+
34
+ Fetch product and raw file metadata from the Cloudnet data portal.
35
+
36
+ Parameters:
37
+
38
+ | name | type | default | example |
39
+ | --------------- | ------------------------ | ------- | ---------------------------------------------------- |
40
+ | site_id | `str` | | "hyytiala" |
41
+ | date | `str` or `datetime.date` | `None` | "2024-01-01" |
42
+ | date_from | `str` or `datetime.date` | `None` | "2025-01-01" |
43
+ | date_to | `str` or `datetime.date` | `None` | "2025-01-01" |
44
+ | updated_at_from | `str` or `datetime.date` | `None` | "2025-01-01" |
45
+ | updated_at_to | `str` or `datetime.date` | `None` | "2025-01-01" |
46
+ | instrument_id | `str` or `[str]` | `None` | "rpg-fmcw-94" |
47
+ | instrument_pid | `str` or `[str]` | `None` | "https://hdl.handle.net/21.12132/3.191564170f8a4686" |
48
+ | product\* | `str` or `[str]` | `None` | "classification" |
49
+ | show_legacy\* | `bool` | `False` | |
50
+
51
+ \* = only in `metadata()`
52
+
53
+ **Date Handling**
54
+
55
+ The `date` parameter supports:
56
+
57
+ - "YYYY-MM-DD" — a specific date
58
+ - "YYYY-MM" — the entire month
59
+ - "YYYY" — the entire year
60
+ - Or directly as `datetime.date` object
61
+
62
+ The `date_from`, `date_to`, `updated_at_from` and `updated_at_to` parameters
63
+ should be of form "YYYY-MM-DD" or `datetime.date`. Note that, if `date` is defined, `date_from` and `date_to` have no effect.
64
+
65
+ **Return value**
66
+
67
+ Both methods return a list of `dataclass` instances, `ProductMetadata` and `RawMetadata`, respectively.
68
+
69
+ ### `APIClient().filter([Metadata])` &rarr; `[Metadata]`
70
+
71
+ Additional filtering of fetched metadata.
72
+
73
+ Parameters:
74
+
75
+ | name | type | default |
76
+ | ------------------ | -------------------------------------- | ------- |
77
+ | metadata | `[RawMetadata]` or `[ProductMetadata]` | |
78
+ | include_pattern | `str` | `None` |
79
+ | exclude_pattern | `str` | `None` |
80
+ | filename_prefix | `str` | `None` |
81
+ | filename_suffix | `str` | `None` |
82
+ | include_tag_subset | `{str}` | `None` |
83
+ | exclude_tag_subset | `{str}` | `None` |
84
+
85
+ ### `APIClient().sites()` &rarr; `[Site]`
86
+
87
+ Fetch cloudnet sites.
88
+
89
+ Parameters:
90
+
91
+ | name | type | Choices | default |
92
+ | ---- | ---------------- | ----------------------------------------- | ------- |
93
+ | type | `str` or `[str]` | "cloudnet", "campaign", "model", "hidden" | `None` |
94
+
95
+ ### `APIClient().products()` &rarr; `[Product]`
96
+
97
+ Fetch cloudnet products.
98
+
99
+ Parameters:
100
+
101
+ | name | type | Choices | default |
102
+ | ---- | ---------------- | ----------------------------------------- | ------- |
103
+ | type | `str` or `[str]` | "instrument", "geophysical", "evaluation" | `None` |
104
+
105
+ ### `cloudnet_api_client.download([Metadata])`
106
+
107
+ Download files from the fetched metadata.
108
+
109
+ Parameters:
110
+
111
+ | name | type | default |
112
+ | ----------------- | -------------------------------------- | ------- |
113
+ | metadata | `[RawMetadata]` or `[ProductMetadata]` | |
114
+ | output_directory | `PathLike` or `str` | |
115
+ | concurrency_limit | `int` | 5 |
116
+
117
+ ## License
118
+
119
+ MIT
@@ -56,6 +56,8 @@ class APIClient:
56
56
  date: DateParam = None,
57
57
  date_from: DateParam = None,
58
58
  date_to: DateParam = None,
59
+ updated_at_from: DateParam = None,
60
+ updated_at_to: DateParam = None,
59
61
  instrument_id: QueryParam = None,
60
62
  instrument_pid: QueryParam = None,
61
63
  product: QueryParam = None,
@@ -68,7 +70,9 @@ class APIClient:
68
70
  "product": product,
69
71
  "showLegacy": show_legacy,
70
72
  }
71
- date_params = self._mangle_dates(date, date_from, date_to)
73
+ date_params = self._mangle_dates(
74
+ date, date_from, date_to, updated_at_from, updated_at_to
75
+ )
72
76
  params.update(date_params)
73
77
  res = self._get_response("files", params)
74
78
  return _build_objects(res, ProductMetadata)
@@ -79,6 +83,8 @@ class APIClient:
79
83
  date: DateParam = None,
80
84
  date_from: DateParam = None,
81
85
  date_to: DateParam = None,
86
+ updated_at_from: DateParam = None,
87
+ updated_at_to: DateParam = None,
82
88
  instrument_id: QueryParam = None,
83
89
  instrument_pid: QueryParam = None,
84
90
  ) -> list[RawMetadata]:
@@ -87,7 +93,9 @@ class APIClient:
87
93
  "instrument": instrument_id,
88
94
  "instrumentPid": instrument_pid,
89
95
  }
90
- date_params = self._mangle_dates(date, date_from, date_to)
96
+ date_params = self._mangle_dates(
97
+ date, date_from, date_to, updated_at_from, updated_at_to
98
+ )
91
99
  params.update(date_params)
92
100
  res = self._get_response("raw-files", params)
93
101
  return _build_raw_meta_objects(res)
@@ -139,10 +147,17 @@ class APIClient:
139
147
  return res.json()
140
148
 
141
149
  def _mangle_dates(
142
- self, date: DateParam, date_from: DateParam, date_to: DateParam
150
+ self,
151
+ date: DateParam,
152
+ date_from: DateParam,
153
+ date_to: DateParam,
154
+ updated_at_from: DateParam,
155
+ updated_at_to: DateParam,
143
156
  ) -> dict:
144
157
  params = {}
145
- if isinstance(date, str):
158
+ if isinstance(date, datetime.date):
159
+ params["date"] = date
160
+ elif isinstance(date, str):
146
161
  if re.fullmatch(r"\d{4}-\d{2}-\d{2}", date):
147
162
  params["date"] = self._parse_date(date)
148
163
  elif re.fullmatch(r"\d{4}-\d{2}", date):
@@ -155,13 +170,15 @@ class APIClient:
155
170
  params["dateTo"] = datetime.date(int(date), 12, 31)
156
171
  else:
157
172
  raise ValueError("Invalid date format")
158
- elif isinstance(date, datetime.date):
159
- params["date"] = date
160
173
  else:
161
174
  if date_from:
162
175
  params["dateFrom"] = self._parse_date(date_from)
163
176
  if date_to:
164
177
  params["dateTo"] = self._parse_date(date_to)
178
+ if updated_at_from:
179
+ params["updatedAtFrom"] = self._parse_date(updated_at_from)
180
+ if updated_at_to:
181
+ params["updatedAtTo"] = self._parse_date(updated_at_to)
165
182
  return params
166
183
 
167
184
  @staticmethod
@@ -0,0 +1 @@
1
+ __version__ = "0.1.1"
@@ -1,90 +0,0 @@
1
- [![CI](https://github.com/actris-cloudnet/cloudnet-api-client/actions/workflows/test.yml/badge.svg)](https://github.com/actris-cloudnet/cloudnet-api-client/actions/workflows/test.yml)
2
-
3
- # cloudnet-api-client
4
-
5
- Official Python package for using Cloudnet API
6
-
7
- ## Quickstart
8
-
9
- ```python
10
- import cloudnet_api_client as cac
11
-
12
- client = cac.APIClient()
13
-
14
- sites = client.sites(type="cloudnet")
15
- products = client.products()
16
-
17
- metadata = client.metadata("hyytiala", "2021-01-01", product=["mwr", "radar"])
18
- cac.download(metadata, "data")
19
-
20
- raw_metadata = client.metadata("hyytiala", "2021-01-01")
21
- cac.download(raw_metadata, "data_raw")
22
- ```
23
-
24
- ## Documentation
25
-
26
- ### `APIClient().metadata()` and `raw_metadata()` &rarr; `[Metadata]`
27
-
28
- Fetch product and raw file metadata from the Cloudnet data portal.
29
-
30
- Parameters:
31
-
32
- | name | type | default | example |
33
- | -------------- | ------------------------ | ------- | ---------------------------------------------------- |
34
- | site_id | `str` | | "hyytiala" |
35
- | date | `str` or `datetime.date` | `None` | "2024-01-01" |
36
- | date_from | `str` or `datetime.date` | `None` | "2025-01-01" |
37
- | date_to | `str` or `datetime.date` | `None` | "2025-01-01" |
38
- | instrument_id | `str` or `[str]` | `None` | "rpg-fmcw-94" |
39
- | instrument_pid | `str` or `[str]` | `None` | "https://hdl.handle.net/21.12132/3.191564170f8a4686" |
40
- | product\* | `str` or `[str]` | `None` | "classification" |
41
- | show_legacy\* | `bool` | `False` | |
42
-
43
- \* = only in `metadata()`
44
-
45
- **Date Handling**
46
-
47
- The `date` parameter supports:
48
-
49
- - "YYYY-MM-DD" — a specific date
50
- - "YYYY-MM" — the entire month
51
- - "YYYY" — the entire year
52
- - Or directly as `datetime.date` object
53
-
54
- The `date_from` and `date_to` parameters should be "YYYY-MM-DD" or `datetime.date`. If `date` is defined, `date_from` and `date_to` have no effect.
55
-
56
- **Return value**
57
-
58
- Both methods return a list of `dataclass` instances, `ProductMetadata` and `RawMetadata`, respectively.
59
-
60
- ### `APIClient().filter([Metadata])` &rarr; `[Metadata]`
61
-
62
- Additional filtering of fetched metadata.
63
-
64
- Parameters:
65
-
66
- | name | type | default |
67
- | ------------------ | -------------------------------------- | ------- |
68
- | metadata | `[RawMetadata]` or `[ProductMetadata]` | |
69
- | include_pattern | `str` | `None` |
70
- | exclude_pattern | `str` | `None` |
71
- | filename_prefix | `str` | `None` |
72
- | filename_suffix | `str` | `None` |
73
- | include_tag_subset | `{str}` | `None` |
74
- | exclude_tag_subset | `{str}` | `None` |
75
-
76
- ### `cloudnet_api_client.download([Metadata])`
77
-
78
- Function to download files from fetched metadata.
79
-
80
- Parameters:
81
-
82
- | name | type | default |
83
- | ----------------- | -------------------------------------- | ------- |
84
- | metadata | `[RawMetadata]` or `[ProductMetadata]` | |
85
- | output_directory | `PathLike` | |
86
- | concurrency_limit | `int` | 5 |
87
-
88
- ## License
89
-
90
- MIT
@@ -1 +0,0 @@
1
- __version__ = "0.1.0"