diff --git a/awxkit/awxkit/api/pages/credentials.py b/awxkit/awxkit/api/pages/credentials.py index d5ba0c4d05..f964ae38e4 100644 --- a/awxkit/awxkit/api/pages/credentials.py +++ b/awxkit/awxkit/api/pages/credentials.py @@ -82,6 +82,7 @@ def config_cred_from_kind(kind): credential_type_name_to_config_kind_map = { 'amazon web services': 'aws', + 'ansible galaxy/automation hub api token': 'galaxy', 'ansible tower': 'tower', 'google compute engine': 'gce', 'insights': 'insights', diff --git a/awxkit/awxkit/api/pages/organizations.py b/awxkit/awxkit/api/pages/organizations.py index 413ecf4961..e1d13a0013 100644 --- a/awxkit/awxkit/api/pages/organizations.py +++ b/awxkit/awxkit/api/pages/organizations.py @@ -22,6 +22,24 @@ class Organization(HasCreate, HasInstanceGroups, HasNotifications, base.Base): with suppress(exc.NoContent): self.related.users.post(user) + def add_galaxy_credential(self, credential): + if isinstance(credential, page.Page): + credential = credential.json + with suppress(exc.NoContent): + self.related.galaxy_credentials.post({ + "id": credential.id, + }) + + def remove_galaxy_credential(self, credential): + if isinstance(credential, page.Page): + credential = credential.json + with suppress(exc.NoContent): + self.related.galaxy_credentials.post({ + "id": credential.id, + "disassociate": True, + }) + + def payload(self, **kwargs): payload = PseudoNamespace(name=kwargs.get('name') or 'Organization - {}'.format(random_title()), description=kwargs.get('description') or random_title(10))