{"id":28153199,"url":"https://github.com/adam0brien/inventory-payload-generator","last_synced_at":"2025-05-15T05:13:26.447Z","repository":{"id":289741552,"uuid":"970938064","full_name":"Adam0Brien/inventory-payload-generator","owner":"Adam0Brien","description":"payload generator for inventory-api that uses json schema and openapi spec","archived":false,"fork":false,"pushed_at":"2025-04-24T19:48:36.000Z","size":137,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T20:36:38.682Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Adam0Brien.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-22T19:04:38.000Z","updated_at":"2025-04-24T19:48:39.000Z","dependencies_parsed_at":"2025-04-24T20:46:57.406Z","dependency_job_id":null,"html_url":"https://github.com/Adam0Brien/inventory-payload-generator","commit_stats":null,"previous_names":["adam0brien/inventory-payload-generator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adam0Brien%2Finventory-payload-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adam0Brien%2Finventory-payload-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adam0Brien%2Finventory-payload-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adam0Brien%2Finventory-payload-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Adam0Brien","download_url":"https://codeload.github.com/Adam0Brien/inventory-payload-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276423,"owners_count":22043869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-15T05:13:16.238Z","updated_at":"2025-05-15T05:13:26.434Z","avatar_url":"https://github.com/Adam0Brien.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Inventory Payload Generator\n\nThis CLI tool generates valid example payloads for the [Kessel inventory-api](https://github.com/project-kessel/inventory-api), based on its OpenAPI spec and JSON schemas.\n\nIt supports:\n- Inferring values from the OpenAPI + JSON Schema filesystem structure\n- Sending POST and DELETE requests to the inventory-api resource endpoint\n- Saving generated payloads to disk\n\n![demo](https://github.com/Adam0Brien/inventory-payload-generator/blob/main/demo.gif)\n\n## Setup\n\n```bash\nmake setup\n```\n\n## Usage\n\nCLI arguments are used to decide what type of resource you want to generate along with where you want to send it. \n\n#### Example:\n\"I want a `host` resource with reporter type `HBI` and I would like the payload saved to `payloads/host_HBI.json`\"\n\n```py\ninvgen \\\n  --resource host \\\n  --reporter HBI \\\n  --output payloads/host_HBI.json\n```\n\n### CLI arguments\n\n```py\ninvgen --help\n\n```\n\n| Option                | Description                                                   |\n|-----------------------|---------------------------------------------------------------|\n| `--post URL`          | Send the payload as a POST to the given endpoint              |\n| `--delete URL`        | Send the payload as a DELETE request                          |\n| `--resource`          | Resource type (e.g. `host`, required for POST)          |\n| `--reporter`          | Reporter type (e.g. `HBI`, required for both POST and DELETE) |\n| `--local-resource-id` | Local resource ID to delete (required for DELETE)             |\n| `--inventory-id`      | Optionally set the inventory ID in the payload                |\n| `--output FILE.json`  | Save the generated payload to a file                          |\n| `--quiet`             | Suppress logs                                                 |\n\n\n#### Another example\n\nGenerating a hbi host, posting the payload, saving to file\n```py\ninvgen \\\n  --resource host \\\n  --reporter HBI \\\n  --post http://localhost:8000/api/inventory/v1beta2/resources \\\n  --output payloads/host_HBI.json --quiet\n\nLogging disabled via --quiet\nFinal Payload:\n{\n  \"resource\": {\n    \"resourceType\": \"host\",\n    \"reporterType\": \"HBI\",\n    \"reporterInstanceId\": \"776225b7-c857-4690-ae22-d6e66bbab519\",\n    \"resourceRepresentation\": {\n      \"representationMetadata\": {\n        \"localResourceId\": \"4fcc4047-7133-4ac9-9405-9064496ad9c2\",\n        \"apiHref\": \"http://morris.com/\",\n        \"consoleHref\": \"http://matthews.info/\",\n        \"reporterVersion\": \"1.0.6\"\n      },\n      \"common\": {\n        \"workspace_id\": \"44aab1e1-c323-4d7c-88e0-79ac4d468ff6\"\n      },\n      \"reporter\": {\n        \"satellite_id\": \"c7c73f12-7dd6-41ce-a7ed-1158e06b652a\",\n        \"sub_manager_id\": \"1a159006-d2dc-4604-95fd-d727d0d16e5c\",\n        \"insights_inventory_id\": \"4296814e-d050-4cc5-a9e6-5f71360c3569\",\n        \"ansible_host\": \"police\"\n      }\n    }\n  }\n}\n\nStatus: 200\nResponse:\n{}\n```\n\nDeleting the hbi host (Ensure `local-resource-id` is the same)\n```py\ninvgen \\\n  --reporter HBI \\\n  --local-resource-id 4fcc4047-7133-4ac9-9405-9064496ad9c2 \\\n  --delete http://localhost:8000/api/inventory/v1beta2/resources --quiet\n\nLogging disabled via --quiet\nFinal Payload:\n{\n  \"localResourceId\": \"4fcc4047-7133-4ac9-9405-9064496ad9c2\",\n  \"reporterType\": \"HBI\"\n}\nStatus: 200\nResponse:\n{}\n\n```\n\n# Note\nIf the cli does not work run with python\n```sh\npython main.py --resource host --reporter HBI --output HBI_host.json\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam0brien%2Finventory-payload-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadam0brien%2Finventory-payload-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam0brien%2Finventory-payload-generator/lists"}