We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add insignts_credential paramter to tower_inventory
<!-- Issues are for **concrete, actionable bugs and feature requests** only - if you're just asking for debugging help or technical support, please use:

- http://webchat.freenode.net/?channels=ansible-awx
- https://groups.google.com/forum/#!forum/awx-project

We have to limit this because of limited volunteer time to respond to issues! -->

##### ISSUE TYPE
 - Feature Idea

##### SUMMARY
<!-- Briefly describe the problem or desired enhancement. -->
Per PR #7963 tower_inventory is missing support for the insights_credential API parameter.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `awx_collection/plugins/modules/tower_inventory.py`
Content:
```
1 #!/usr/bin/python
2 # coding: utf-8 -*-
3 
4 # (c) 2017, Wayne Witzel III <wayne@riotousliving.com>
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6 
7 from __future__ import absolute_import, division, print_function
8 __metaclass__ = type
9 
10 
11 ANSIBLE_METADATA = {'metadata_version': '1.1',
12                     'status': ['preview'],
13                     'supported_by': 'community'}
14 
15 
16 DOCUMENTATION = '''
17 ---
18 module: tower_inventory
19 author: "Wayne Witzel III (@wwitzel3)"
20 short_description: create, update, or destroy Ansible Tower inventory.
21 description:
22     - Create, update, or destroy Ansible Tower inventories. See
23       U(https://www.ansible.com/tower) for an overview.
24 options:
25     name:
26       description:
27         - The name to use for the inventory.
28       required: True
29       type: str
30     description:
31       description:
32         - The description to use for the inventory.
33       type: str
34     organization:
35       description:
36         - Organization the inventory belongs to.
37       required: True
38       type: str
39     variables:
40       description:
41         - Inventory variables.
42       type: dict
43     kind:
44       description:
45         - The kind field. Cannot be modified after created.
46       default: ""
47       choices: ["", "smart"]
48       type: str
49     host_filter:
50       description:
51         -  The host_filter field. Only useful when C(kind=smart).
52       type: str
53     state:
54       description:
55         - Desired state of the resource.
56       default: "present"
57       choices: ["present", "absent"]
58       type: str
59 extends_documentation_fragment: awx.awx.auth
60 '''
61 
62 
63 EXAMPLES = '''
64 - name: Add tower inventory
65   tower_inventory:
66     name: "Foo Inventory"
67     description: "Our Foo Cloud Servers"
68     organization: "Bar Org"
69     state: present
70     tower_config_file: "~/tower_cli.cfg"
71 '''
72 
73 
74 from ..module_utils.tower_api import TowerAPIModule
75 import json
76 
77 
78 def main():
79     # Any additional arguments that are not fields of the item can be added here
80     argument_spec = dict(
81         name=dict(required=True),
82         description=dict(),
83         organization=dict(required=True),
84         variables=dict(type='dict'),
85         kind=dict(choices=['', 'smart'], default=''),
86         host_filter=dict(),
87         state=dict(choices=['present', 'absent'], default='present'),
88     )
89 
90     # Create a module for ourselves
91     module = TowerAPIModule(argument_spec=argument_spec)
92 
93     # Extract our parameters
94     name = module.params.get('name')
95     description = module.params.get('description')
96     organization = module.params.get('organization')
97     variables = module.params.get('variables')
98     state = module.params.get('state')
99     kind = module.params.get('kind')
100     host_filter = module.params.get('host_filter')
101 
102     # Attempt to look up the related items the user specified (these will fail the module if not found)
103     org_id = module.resolve_name_to_id('organizations', organization)
104 
105     # Attempt to look up inventory based on the provided name and org ID
106     inventory = module.get_one('inventories', **{
107         'data': {
108             'name': name,
109             'organization': org_id
110         }
111     })
112 
113     if state == 'absent':
114         # If the state was absent we can let the module delete it if needed, the module will handle exiting from this
115         module.delete_if_needed(inventory)
116 
117     # Create the data that gets sent for create and update
118     inventory_fields = {
119         'name': name,
120         'organization': org_id,
121         'kind': kind,
122         'host_filter': host_filter,
123     }
124     if description is not None:
125         inventory_fields['description'] = description
126     if variables is not None:
127         inventory_fields['variables'] = json.dumps(variables)
128 
129     # We need to perform a check to make sure you are not trying to convert a regular inventory into a smart one.
130     if inventory and inventory['kind'] == '' and inventory_fields['kind'] == 'smart':
131         module.fail_json(msg='You cannot turn a regular inventory into a "smart" inventory.')
132 
133     # If the state was present and we can let the module build or update the existing inventory, this will return on its own
134     module.create_or_update_if_needed(inventory, inventory_fields, endpoint='inventories', item_type='inventory')
135 
136 
137 if __name__ == '__main__':
138     main()
139
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/awx_collection/plugins/modules/tower_inventory.py b/awx_collection/plugins/modules/tower_inventory.py
--- a/awx_collection/plugins/modules/tower_inventory.py
+++ b/awx_collection/plugins/modules/tower_inventory.py
@@ -48,7 +48,11 @@
       type: str
     host_filter:
       description:
-        -  The host_filter field. Only useful when C(kind=smart).
+        - The host_filter field. Only useful when C(kind=smart).
+      type: str
+    insights_credential:
+      description:
+        - Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.
       type: str
     state:
       description:
@@ -84,6 +88,7 @@
         variables=dict(type='dict'),
         kind=dict(choices=['', 'smart'], default=''),
         host_filter=dict(),
+        insights_credential=dict(),
         state=dict(choices=['present', 'absent'], default='present'),
     )
 
@@ -98,6 +103,7 @@
     state = module.params.get('state')
     kind = module.params.get('kind')
     host_filter = module.params.get('host_filter')
+    insights_credential = module.params.get('insights_credential')
 
     # Attempt to look up the related items the user specified (these will fail the module if not found)
     org_id = module.resolve_name_to_id('organizations', organization)
@@ -125,6 +131,8 @@
         inventory_fields['description'] = description
     if variables is not None:
         inventory_fields['variables'] = json.dumps(variables)
+    if insights_credential is not None:
+        inventory_fields['insights_credential'] = module.resolve_name_to_id('credentials', insights_credential)
 
     # We need to perform a check to make sure you are not trying to convert a regular inventory into a smart one.
     if inventory and inventory['kind'] == '' and inventory_fields['kind'] == 'smart':

{"golden_diff": "diff --git a/awx_collection/plugins/modules/tower_inventory.py b/awx_collection/plugins/modules/tower_inventory.py\n--- a/awx_collection/plugins/modules/tower_inventory.py\n+++ b/awx_collection/plugins/modules/tower_inventory.py\n@@ -48,7 +48,11 @@\n       type: str\n     host_filter:\n       description:\n-        -  The host_filter field. Only useful when C(kind=smart).\n+        - The host_filter field. Only useful when C(kind=smart).\n+      type: str\n+    insights_credential:\n+      description:\n+        - Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.\n       type: str\n     state:\n       description:\n@@ -84,6 +88,7 @@\n         variables=dict(type='dict'),\n         kind=dict(choices=['', 'smart'], default=''),\n         host_filter=dict(),\n+        insights_credential=dict(),\n         state=dict(choices=['present', 'absent'], default='present'),\n     )\n \n@@ -98,6 +103,7 @@\n     state = module.params.get('state')\n     kind = module.params.get('kind')\n     host_filter = module.params.get('host_filter')\n+    insights_credential = module.params.get('insights_credential')\n \n     # Attempt to look up the related items the user specified (these will fail the module if not found)\n     org_id = module.resolve_name_to_id('organizations', organization)\n@@ -125,6 +131,8 @@\n         inventory_fields['description'] = description\n     if variables is not None:\n         inventory_fields['variables'] = json.dumps(variables)\n+    if insights_credential is not None:\n+        inventory_fields['insights_credential'] = module.resolve_name_to_id('credentials', insights_credential)\n \n     # We need to perform a check to make sure you are not trying to convert a regular inventory into a smart one.\n     if inventory and inventory['kind'] == '' and inventory_fields['kind'] == 'smart':\n", "issue": "Add insignts_credential paramter to tower_inventory\n<!-- Issues are for **concrete, actionable bugs and feature requests** only - if you're just asking for debugging help or technical support, please use:\r\n\r\n- http://webchat.freenode.net/?channels=ansible-awx\r\n- https://groups.google.com/forum/#!forum/awx-project\r\n\r\nWe have to limit this because of limited volunteer time to respond to issues! -->\r\n\r\n##### ISSUE TYPE\r\n - Feature Idea\r\n\r\n##### SUMMARY\r\n<!-- Briefly describe the problem or desired enhancement. -->\r\nPer PR #7963 tower_inventory is missing support for the insights_credential API parameter.\n", "before_files": [{"content": "#!/usr/bin/python\n# coding: utf-8 -*-\n\n# (c) 2017, Wayne Witzel III <wayne@riotousliving.com>\n# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)\n\nfrom __future__ import absolute_import, division, print_function\n__metaclass__ = type\n\n\nANSIBLE_METADATA = {'metadata_version': '1.1',\n                    'status': ['preview'],\n                    'supported_by': 'community'}\n\n\nDOCUMENTATION = '''\n---\nmodule: tower_inventory\nauthor: \"Wayne Witzel III (@wwitzel3)\"\nshort_description: create, update, or destroy Ansible Tower inventory.\ndescription:\n    - Create, update, or destroy Ansible Tower inventories. See\n      U(https://www.ansible.com/tower) for an overview.\noptions:\n    name:\n      description:\n        - The name to use for the inventory.\n      required: True\n      type: str\n    description:\n      description:\n        - The description to use for the inventory.\n      type: str\n    organization:\n      description:\n        - Organization the inventory belongs to.\n      required: True\n      type: str\n    variables:\n      description:\n        - Inventory variables.\n      type: dict\n    kind:\n      description:\n        - The kind field. Cannot be modified after created.\n      default: \"\"\n      choices: [\"\", \"smart\"]\n      type: str\n    host_filter:\n      description:\n        -  The host_filter field. Only useful when C(kind=smart).\n      type: str\n    state:\n      description:\n        - Desired state of the resource.\n      default: \"present\"\n      choices: [\"present\", \"absent\"]\n      type: str\nextends_documentation_fragment: awx.awx.auth\n'''\n\n\nEXAMPLES = '''\n- name: Add tower inventory\n  tower_inventory:\n    name: \"Foo Inventory\"\n    description: \"Our Foo Cloud Servers\"\n    organization: \"Bar Org\"\n    state: present\n    tower_config_file: \"~/tower_cli.cfg\"\n'''\n\n\nfrom ..module_utils.tower_api import TowerAPIModule\nimport json\n\n\ndef main():\n    # Any additional arguments that are not fields of the item can be added here\n    argument_spec = dict(\n        name=dict(required=True),\n        description=dict(),\n        organization=dict(required=True),\n        variables=dict(type='dict'),\n        kind=dict(choices=['', 'smart'], default=''),\n        host_filter=dict(),\n        state=dict(choices=['present', 'absent'], default='present'),\n    )\n\n    # Create a module for ourselves\n    module = TowerAPIModule(argument_spec=argument_spec)\n\n    # Extract our parameters\n    name = module.params.get('name')\n    description = module.params.get('description')\n    organization = module.params.get('organization')\n    variables = module.params.get('variables')\n    state = module.params.get('state')\n    kind = module.params.get('kind')\n    host_filter = module.params.get('host_filter')\n\n    # Attempt to look up the related items the user specified (these will fail the module if not found)\n    org_id = module.resolve_name_to_id('organizations', organization)\n\n    # Attempt to look up inventory based on the provided name and org ID\n    inventory = module.get_one('inventories', **{\n        'data': {\n            'name': name,\n            'organization': org_id\n        }\n    })\n\n    if state == 'absent':\n        # If the state was absent we can let the module delete it if needed, the module will handle exiting from this\n        module.delete_if_needed(inventory)\n\n    # Create the data that gets sent for create and update\n    inventory_fields = {\n        'name': name,\n        'organization': org_id,\n        'kind': kind,\n        'host_filter': host_filter,\n    }\n    if description is not None:\n        inventory_fields['description'] = description\n    if variables is not None:\n        inventory_fields['variables'] = json.dumps(variables)\n\n    # We need to perform a check to make sure you are not trying to convert a regular inventory into a smart one.\n    if inventory and inventory['kind'] == '' and inventory_fields['kind'] == 'smart':\n        module.fail_json(msg='You cannot turn a regular inventory into a \"smart\" inventory.')\n\n    # If the state was present and we can let the module build or update the existing inventory, this will return on its own\n    module.create_or_update_if_needed(inventory, inventory_fields, endpoint='inventories', item_type='inventory')\n\n\nif __name__ == '__main__':\n    main()\n", "path": "awx_collection/plugins/modules/tower_inventory.py"}], "after_files": [{"content": "#!/usr/bin/python\n# coding: utf-8 -*-\n\n# (c) 2017, Wayne Witzel III <wayne@riotousliving.com>\n# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)\n\nfrom __future__ import absolute_import, division, print_function\n__metaclass__ = type\n\n\nANSIBLE_METADATA = {'metadata_version': '1.1',\n                    'status': ['preview'],\n                    'supported_by': 'community'}\n\n\nDOCUMENTATION = '''\n---\nmodule: tower_inventory\nauthor: \"Wayne Witzel III (@wwitzel3)\"\nshort_description: create, update, or destroy Ansible Tower inventory.\ndescription:\n    - Create, update, or destroy Ansible Tower inventories. See\n      U(https://www.ansible.com/tower) for an overview.\noptions:\n    name:\n      description:\n        - The name to use for the inventory.\n      required: True\n      type: str\n    description:\n      description:\n        - The description to use for the inventory.\n      type: str\n    organization:\n      description:\n        - Organization the inventory belongs to.\n      required: True\n      type: str\n    variables:\n      description:\n        - Inventory variables.\n      type: dict\n    kind:\n      description:\n        - The kind field. Cannot be modified after created.\n      default: \"\"\n      choices: [\"\", \"smart\"]\n      type: str\n    host_filter:\n      description:\n        - The host_filter field. Only useful when C(kind=smart).\n      type: str\n    insights_credential:\n      description:\n        - Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.\n      type: str\n    state:\n      description:\n        - Desired state of the resource.\n      default: \"present\"\n      choices: [\"present\", \"absent\"]\n      type: str\nextends_documentation_fragment: awx.awx.auth\n'''\n\n\nEXAMPLES = '''\n- name: Add tower inventory\n  tower_inventory:\n    name: \"Foo Inventory\"\n    description: \"Our Foo Cloud Servers\"\n    organization: \"Bar Org\"\n    state: present\n    tower_config_file: \"~/tower_cli.cfg\"\n'''\n\n\nfrom ..module_utils.tower_api import TowerAPIModule\nimport json\n\n\ndef main():\n    # Any additional arguments that are not fields of the item can be added here\n    argument_spec = dict(\n        name=dict(required=True),\n        description=dict(),\n        organization=dict(required=True),\n        variables=dict(type='dict'),\n        kind=dict(choices=['', 'smart'], default=''),\n        host_filter=dict(),\n        insights_credential=dict(),\n        state=dict(choices=['present', 'absent'], default='present'),\n    )\n\n    # Create a module for ourselves\n    module = TowerAPIModule(argument_spec=argument_spec)\n\n    # Extract our parameters\n    name = module.params.get('name')\n    description = module.params.get('description')\n    organization = module.params.get('organization')\n    variables = module.params.get('variables')\n    state = module.params.get('state')\n    kind = module.params.get('kind')\n    host_filter = module.params.get('host_filter')\n    insights_credential = module.params.get('insights_credential')\n\n    # Attempt to look up the related items the user specified (these will fail the module if not found)\n    org_id = module.resolve_name_to_id('organizations', organization)\n\n    # Attempt to look up inventory based on the provided name and org ID\n    inventory = module.get_one('inventories', **{\n        'data': {\n            'name': name,\n            'organization': org_id\n        }\n    })\n\n    if state == 'absent':\n        # If the state was absent we can let the module delete it if needed, the module will handle exiting from this\n        module.delete_if_needed(inventory)\n\n    # Create the data that gets sent for create and update\n    inventory_fields = {\n        'name': name,\n        'organization': org_id,\n        'kind': kind,\n        'host_filter': host_filter,\n    }\n    if description is not None:\n        inventory_fields['description'] = description\n    if variables is not None:\n        inventory_fields['variables'] = json.dumps(variables)\n    if insights_credential is not None:\n        inventory_fields['insights_credential'] = module.resolve_name_to_id('credentials', insights_credential)\n\n    # We need to perform a check to make sure you are not trying to convert a regular inventory into a smart one.\n    if inventory and inventory['kind'] == '' and inventory_fields['kind'] == 'smart':\n        module.fail_json(msg='You cannot turn a regular inventory into a \"smart\" inventory.')\n\n    # If the state was present and we can let the module build or update the existing inventory, this will return on its own\n    module.create_or_update_if_needed(inventory, inventory_fields, endpoint='inventories', item_type='inventory')\n\n\nif __name__ == '__main__':\n    main()\n", "path": "awx_collection/plugins/modules/tower_inventory.py"}]}