Update awxkit to manage Org galaxy credentials

Add the new credential type to the Credential page object and helper
methods to manage the galaxy credentials for the Organization page
object.
This commit is contained in:
Elyézer Rezende
2020-09-01 11:56:46 -04:00
committed by Ryan Petrello
parent 4046b18eff
commit ad85b176f4
2 changed files with 19 additions and 0 deletions

View File

@@ -82,6 +82,7 @@ def config_cred_from_kind(kind):
credential_type_name_to_config_kind_map = { credential_type_name_to_config_kind_map = {
'amazon web services': 'aws', 'amazon web services': 'aws',
'ansible galaxy/automation hub api token': 'galaxy',
'ansible tower': 'tower', 'ansible tower': 'tower',
'google compute engine': 'gce', 'google compute engine': 'gce',
'insights': 'insights', 'insights': 'insights',

View File

@@ -22,6 +22,24 @@ class Organization(HasCreate, HasInstanceGroups, HasNotifications, base.Base):
with suppress(exc.NoContent): with suppress(exc.NoContent):
self.related.users.post(user) 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): def payload(self, **kwargs):
payload = PseudoNamespace(name=kwargs.get('name') or 'Organization - {}'.format(random_title()), payload = PseudoNamespace(name=kwargs.get('name') or 'Organization - {}'.format(random_title()),
description=kwargs.get('description') or random_title(10)) description=kwargs.get('description') or random_title(10))