schubergphilis / towerlib

A python library to interface with ansible tower's (awx) api.
MIT License
43 stars 39 forks source link

"copy" features are missed. #95

Open hongzhaoo opened 2 years ago

hongzhaoo commented 2 years ago

on awx web UI, users may create job templates or inventories by copying existing ones. it would be great helpful if the towerlib supports theses features.

phospi commented 2 years ago

Yes, you may be right. But while waiting for someone to fix that, there is neat workaround to excute a copy action with towerlib:

towerlib = Tower("tower.com", "tower_user", "tower_pw", secure=True, ssl_verify=False)

job_template = towerlib_obj.get_job_template_by_name("My Job Template")
relative_url_copy = job_template.__dict__['_data']['related']['copy']

url = f'{towerlib.api[:-7]}{relative_url_copy}'
new_job_template_name = { "name": f'{job_template.name} - Copy' }

new_job_template = towerlib.session.post(url, json=new_job_template_name)
costastf commented 2 years ago

This should be easy to implement. I will try to make some time next week for this.

hongzhaoo commented 2 years ago

@phospi @costastf thank you guys.

costastf commented 2 years ago

@hongzhaoo, @phospi apologies for not picking this up, but I have been busy with the birth of my son and parental leave. Any chance @phospi you would like to provide a PR with the feature?

phospi commented 2 years ago

@costastf Sorry, we are currently short-staffed. The workaround is sufficient for us. We don't plan to implement this feature at the time being.

costastf commented 2 years ago

Thanks @phospi I appreciate the response.