prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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.
  
  </issue>
  <code>
  [start of awx_collection/plugins/modules/tower_inventory.py]
  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 of awx_collection/plugins/modules/tower_inventory.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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':
  
verification_info: {"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"}]}