canonicalwebteam.store-api 6.5.0__py3-none-any.whl → 6.7.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.
@@ -53,7 +53,7 @@ class Base:
53
53
  response.status_code,
54
54
  error_list,
55
55
  )
56
- else:
56
+ elif not body:
57
57
  raise StoreApiResponseError(
58
58
  "Unknown error from api", response.status_code
59
59
  )
@@ -1,5 +1,5 @@
1
1
  from os import getenv
2
- from typing import Optional
2
+ from typing import Optional, Union
3
3
  from requests import Session
4
4
 
5
5
  from canonicalwebteam.store_api.base import Base
@@ -246,7 +246,7 @@ class PublisherGW(Base):
246
246
  processed_response = self.process_response(response)
247
247
 
248
248
  if "metadata" not in processed_response:
249
- raise KeyError("Missing 'metadata' key in response")
249
+ return processed_response
250
250
 
251
251
  return processed_response["metadata"]
252
252
 
@@ -312,7 +312,7 @@ class PublisherGW(Base):
312
312
  return self.process_response(response)
313
313
 
314
314
  def unregister_package_name(
315
- self, publisher_auth: str, package_name: str
315
+ self, publisher_auth: Union[str, dict], package_name: str
316
316
  ) -> dict:
317
317
  """
318
318
  Unregister a package name.
@@ -328,9 +328,29 @@ class PublisherGW(Base):
328
328
  Otherwise, returns an error list
329
329
  """
330
330
  url = self.get_endpoint_url(package_name, has_name_space=True)
331
+ if self.name_space == "snap":
332
+ # for Snap packages, `unregister_package` uses SCA's API under the
333
+ # hood: this means we must pass the authorization header as if
334
+ # we were calling SCA
335
+ if not isinstance(publisher_auth, dict):
336
+ raise TypeError(
337
+ "Name space 'snap' requires a 'dict' as 'publisher_auth'"
338
+ )
339
+ authorization_header = dashboard_authorization_header(
340
+ publisher_auth
341
+ )
342
+ else:
343
+ if not isinstance(publisher_auth, str):
344
+ raise TypeError(
345
+ f"Name space '{self.name_space}' requires a 'str' as "
346
+ "'publisher_auth'"
347
+ )
348
+ authorization_header = self._get_authorization_header(
349
+ publisher_auth
350
+ )
331
351
  response = self.session.delete(
332
352
  url=url,
333
- headers=self._get_authorization_header(publisher_auth),
353
+ headers=authorization_header,
334
354
  )
335
355
  return response
336
356
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: canonicalwebteam.store-api
3
- Version: 6.5.0
3
+ Version: 6.7.0
4
4
  Summary:
5
5
  License: LGPL-3.0
6
6
  Author: Canonical Web Team
@@ -1,11 +1,11 @@
1
1
  canonicalwebteam/__init__.py,sha256=ED6jHcYiuYpr_0vjGz0zx2lrrmJT9sDJCzIljoDfmlM,65
2
2
  canonicalwebteam/exceptions.py,sha256=A49LRhiEIfXNB2zC-zNcZEcdh0ugw6G7fBbXbs-BWxA,1517
3
3
  canonicalwebteam/store_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- canonicalwebteam/store_api/base.py,sha256=DPJSqp25vk7905Rdebz449vUs2CWyo5b2titg1o_Fvc,2405
4
+ canonicalwebteam/store_api/base.py,sha256=DmfVcefWxGYNQxzYmaDVhmthTCg2vEwEnvczU9Bk5zE,2414
5
5
  canonicalwebteam/store_api/dashboard.py,sha256=M5JLjTTahN-bfiVz9SuP6ahLjqEvOalwmNim6X5Ky6o,22796
6
6
  canonicalwebteam/store_api/devicegw.py,sha256=YXmVXdHCZhukNHJq-eaFUCxa2VxqLT8qt19UrqgXGN0,9777
7
- canonicalwebteam/store_api/publishergw.py,sha256=BLA80XXIisPV30xpz8FGILN7nSy6QOlgZySjfJbBQfQ,28872
8
- canonicalwebteam_store_api-6.5.0.dist-info/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
9
- canonicalwebteam_store_api-6.5.0.dist-info/METADATA,sha256=PqpZZlEmH7DZ2DisNHDf6qjEO8PkPURC0D-UGInRlpk,2253
10
- canonicalwebteam_store_api-6.5.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
- canonicalwebteam_store_api-6.5.0.dist-info/RECORD,,
7
+ canonicalwebteam/store_api/publishergw.py,sha256=u2D2Y76xC8ms16XTZcUe_KmRdcyzqOV2g0aN9HYZBrQ,29702
8
+ canonicalwebteam_store_api-6.7.0.dist-info/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
9
+ canonicalwebteam_store_api-6.7.0.dist-info/METADATA,sha256=PJgxFUHDwul_1i3n7LbmZrLHxPNMJB9GPGXDYBUUD_0,2253
10
+ canonicalwebteam_store_api-6.7.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
+ canonicalwebteam_store_api-6.7.0.dist-info/RECORD,,