canonicalwebteam.store-api 6.0.0__tar.gz → 6.2.0__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.
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/PKG-INFO +1 -1
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/store_api/dashboard.py +2 -3
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/store_api/devicegw.py +43 -24
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/pyproject.toml +1 -1
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/LICENSE +0 -0
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/README.md +0 -0
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/__init__.py +0 -0
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/exceptions.py +0 -0
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/store_api/__init__.py +0 -0
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/store_api/base.py +0 -0
- {canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/store_api/publishergw.py +0 -0
|
@@ -259,7 +259,7 @@ class Dashboard(Base):
|
|
|
259
259
|
self,
|
|
260
260
|
session,
|
|
261
261
|
snap_id,
|
|
262
|
-
data: Optional[
|
|
262
|
+
data: Optional[dict] = None,
|
|
263
263
|
files: Optional[list] = None,
|
|
264
264
|
) -> dict:
|
|
265
265
|
"""
|
|
@@ -284,8 +284,7 @@ class Dashboard(Base):
|
|
|
284
284
|
)
|
|
285
285
|
else:
|
|
286
286
|
# API requires a multipart request, but we have no files to
|
|
287
|
-
|
|
288
|
-
# files_array.append(("info", ("", data["info"], "")))
|
|
287
|
+
files_array.append(("info", ("", data["info"], "")))
|
|
289
288
|
data = None
|
|
290
289
|
|
|
291
290
|
screenshot_response = self.session.request(
|
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
from os import getenv
|
|
2
2
|
from typing import Optional
|
|
3
|
-
|
|
4
3
|
from requests import Session
|
|
5
4
|
from canonicalwebteam.store_api.base import Base
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
DEVICEGW_URL = getenv("DEVICEGW_URL", "https://api.snapcraft.io/")
|
|
8
|
+
DEVICEGW_URL_STAGING = getenv(
|
|
9
|
+
"DEVICEGW_URL_STAGING", "https://api.staging.snapcraft.io/"
|
|
10
|
+
)
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class DeviceGW(Base):
|
|
12
|
-
def __init__(
|
|
14
|
+
def __init__(
|
|
15
|
+
self, namespace, session=Session(), store=None, staging=False
|
|
16
|
+
):
|
|
13
17
|
super().__init__(session)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
if staging:
|
|
19
|
+
self.config = {
|
|
20
|
+
1: {
|
|
21
|
+
"base_url": f"{DEVICEGW_URL_STAGING}api/v1/{namespace}s/",
|
|
22
|
+
"headers": {"X-Ubuntu-Series": "16"},
|
|
23
|
+
},
|
|
24
|
+
2: {
|
|
25
|
+
"base_url": f"{DEVICEGW_URL_STAGING}v2/{namespace}s/",
|
|
26
|
+
"headers": {"Snap-Device-Series": "16"},
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
else:
|
|
30
|
+
self.config = {
|
|
31
|
+
1: {
|
|
32
|
+
"base_url": f"{DEVICEGW_URL}api/v1/{namespace}s/",
|
|
33
|
+
"headers": {"X-Ubuntu-Series": "16"},
|
|
34
|
+
},
|
|
35
|
+
2: {
|
|
36
|
+
"base_url": f"{DEVICEGW_URL}v2/{namespace}s/",
|
|
37
|
+
"headers": {"Snap-Device-Series": "16"},
|
|
38
|
+
},
|
|
39
|
+
}
|
|
24
40
|
|
|
25
41
|
if store:
|
|
26
42
|
self.config[1]["headers"].update({"X-Ubuntu-Store": store})
|
|
@@ -95,25 +111,28 @@ class DeviceGW(Base):
|
|
|
95
111
|
category: str = "",
|
|
96
112
|
architecture: str = "",
|
|
97
113
|
publisher: str = "",
|
|
98
|
-
featured: str = "
|
|
114
|
+
featured: str = "",
|
|
99
115
|
fields: list = [],
|
|
100
116
|
) -> dict:
|
|
101
117
|
"""
|
|
102
118
|
Documentation: https://api.snapcraft.io/docs/search.html#snaps_find
|
|
103
|
-
Endpoint: [GET] https://api.snapcraft.io/v2/
|
|
119
|
+
Endpoint: [GET] https://api.snapcraft.io/v2/{namespace}/find
|
|
104
120
|
"""
|
|
105
121
|
url = self.get_endpoint_url("find", 2)
|
|
106
122
|
headers = self.config[2].get("headers")
|
|
107
|
-
params = {
|
|
108
|
-
"q": query,
|
|
109
|
-
"category": category,
|
|
110
|
-
"architecture": architecture,
|
|
111
|
-
"publisher": publisher,
|
|
112
|
-
"featured": featured,
|
|
113
|
-
}
|
|
123
|
+
params = {"q": query}
|
|
114
124
|
if fields:
|
|
115
125
|
params["fields"] = ",".join(fields)
|
|
126
|
+
if architecture:
|
|
127
|
+
params["architecture"] = architecture
|
|
128
|
+
if category:
|
|
129
|
+
params["category"] = category
|
|
130
|
+
if publisher:
|
|
131
|
+
params["publisher"] = publisher
|
|
132
|
+
if featured:
|
|
133
|
+
params["featured"] = featured
|
|
116
134
|
response = self.session.get(url, params=params, headers=headers)
|
|
135
|
+
# pprint(response.json())
|
|
117
136
|
return self.process_response(response)
|
|
118
137
|
|
|
119
138
|
def get_all_items(self, size: int, api_version: int = 1) -> dict:
|
|
@@ -193,7 +212,7 @@ class DeviceGW(Base):
|
|
|
193
212
|
"""
|
|
194
213
|
Documentation: https://api.snapcraft.io/docs/info.html
|
|
195
214
|
Endpoint: [GET]
|
|
196
|
-
https://api.snapcraft.io/
|
|
215
|
+
https://api.snapcraft.io/v2/{name_space}/info/{package_name}
|
|
197
216
|
"""
|
|
198
217
|
url = self.get_endpoint_url("info/" + name, api_version)
|
|
199
218
|
params = {}
|
|
@@ -229,7 +248,7 @@ class DeviceGW(Base):
|
|
|
229
248
|
) -> dict:
|
|
230
249
|
"""
|
|
231
250
|
Documentation: https://api.snapcraft.io/docs/categories.html
|
|
232
|
-
Endpoint: https://api.snapcraft.io/
|
|
251
|
+
Endpoint: https://api.snapcraft.io/v2/{name_space}/categories
|
|
233
252
|
"""
|
|
234
253
|
url = self.get_endpoint_url("categories", api_version)
|
|
235
254
|
return self.process_response(
|
|
@@ -247,7 +266,7 @@ class DeviceGW(Base):
|
|
|
247
266
|
Documentation:
|
|
248
267
|
https://api.snapcraft.io/docs/charms.html#list_resource_revisions
|
|
249
268
|
Endpoint:
|
|
250
|
-
https://api.snapcraft.io/
|
|
269
|
+
https://api.snapcraft.io/v2/charms/resources/{package_name}/{resource_name}/revisions
|
|
251
270
|
"""
|
|
252
271
|
url = self.get_endpoint_url(
|
|
253
272
|
f"resources/{name}/{resource_name}/revisions", api_version
|
|
File without changes
|
|
File without changes
|
{canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/__init__.py
RENAMED
|
File without changes
|
{canonicalwebteam_store_api-6.0.0 → canonicalwebteam_store_api-6.2.0}/canonicalwebteam/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|