canonicalwebteam.store-api 6.6.0__tar.gz → 6.7.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: canonicalwebteam.store-api
3
- Version: 6.6.0
3
+ Version: 6.7.0
4
4
  Summary:
5
5
  License: LGPL-3.0
6
6
  Author: Canonical Web Team
@@ -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
@@ -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
  [tool.poetry]
2
2
  name = 'canonicalwebteam.store-api'
3
- version = '6.6.0'
3
+ version = '6.7.0'
4
4
  description = ''
5
5
  authors = ['Canonical Web Team <webteam@canonical.com>']
6
6
  license = 'LGPL-3.0'