tower_cli modify

Hi,

Looking for pointers on how to use the tower_cli modify rest api command. I am able to list, create and delete users in a python script but not able to modify existing one.

Thanks,
Kash

Hi Kash,

Could you please be a little bit more specific as to what exactly is the issue that you are facing while using the tower-cli modify command?

Below are a few pointers to start with:

Command Syntax:

tower-cli user modify {Identifier} {field_to_modify}={value}

  • Identifier is the filed that is used to lookup the resource. Usually, this is the resource name or the ID.

Example: To modify the email of an existing user with ID=23.

`
[root@anawx ~]# tower-cli user modify 23 --email=jeff.bezos@example.com
*** DETAILS: Getting existing record. *****************************************
*** DETAILS: Getting the record. **********************************************
GET http://anawx.example.com/api/v2/users/23/
Params: {}

*** DETAILS: Writing the record. **********************************************
PATCH http://anawx.example.com/api/v2/users/23/
Data: {‘email’: u’jeff.bezos@example.com’}

Resource changed.
== ========== ===================== ========== ========= ============ =================
id username email first_name last_name is_superuser is_system_auditor
== ========== ===================== ========== ========= ============ =================
23 jeff.bezos jeff.bezos@example.com Jeff Bezos false false
== ========== ===================== ========== ========= ============ =================
`

Method Syntax:

def modify(pk=None, create_on_missing=False, kwargs)

  • pk = The primary key for the object to be modified.

  • create_on_missing: Flag if set ‘True’, a new object is created when value for ‘pk’ is not set and the object is not found.

  • kwargs: It is a key-value pair. When value for pk is not set, this key-value pair is used to lookup an existing object.

To get an insight into the usage of modify method in a script, you may refer to the tower-cli API reference .

Hope this is helpful !

Thanks,
Shivharsh

Thanks Shivharsh, I got it working now.