@@ -18,18 +18,22 @@ def request_charmhub_with_retry(self, url, retries):
1818 jasyncio .sleep (5 )
1919 raise JujuError ("Got {} from {}" .format (_response .status_code , url ))
2020
21- def get_charm_id (self , charm_name ):
21+ async def get_charm_id (self , charm_name ):
2222 conn , headers , path_prefix = self .model .connection ().https_connection ()
2323
24- url = "https://api.snapcraft.io/v2/charms/info/{}" .format (charm_name )
24+ model_conf = await self .model .get_config ()
25+ charmhub_url = model_conf ['charmhub-url' ]
26+ url = "{}/v2/charms/info/{}" .format (charmhub_url .value , charm_name )
2527 _response = self .request_charmhub_with_retry (url , 5 )
2628 response = json .loads (_response .text )
2729 return response ['id' ], response ['name' ]
2830
29- def is_subordinate (self , charm_name ):
31+ async def is_subordinate (self , charm_name ):
3032 conn , headers , path_prefix = self .model .connection ().https_connection ()
3133
32- url = "https://api.snapcraft.io/v2/charms/info/{}?fields=default-release.revision.subordinate" .format (charm_name )
34+ model_conf = await self .model .get_config ()
35+ charmhub_url = model_conf ['charmhub-url' ]
36+ url = "{}/v2/charms/info/{}?fields=default-release.revision.subordinate" .format (charmhub_url .value , charm_name )
3337 _response = self .request_charmhub_with_retry (url , 5 )
3438 response = json .loads (_response .text )
3539 return 'subordinate' in response ['default-release' ]['revision' ]
0 commit comments