-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add module to create requests via service catalog #292
Comments
Hi @minsis - Thanks for the idea. What additional value do you think providing a separate module could provide? I agree completely that doing this through builtin.uri is suboptimal (though possible, as you've demonstrated). The "normal" path we'd expect users to follow is to use the generic API module now (as of 2.4.0). Is there something you see a separate module enabling that wouldn't be possible via the API module? |
May i know is this module available now to use for service catalogue ? |
It's in the main branch now, but not yet in a released version. It will be released in version 2.5.0. |
Sorry for the delays I keep forgetting to reply. Seems this is now being applied in some way but I'll still answer just to cover the question. Basically, the value it brings is just like any of the other modules: ease of use and simplicity for the end user. It also brings more functionality to the collection when accounts are limited in usage. Since creating a record on the I think it would be fine just using |
Also to expand it would add ease of use and tracking for building a cart as well. So, in my same example, we could create a cart of the different account types we have and then do a final checkout. With a standard module the user will have the exact known return values needed vs using the generic api module which you need to know what data your api is going to return. |
@minsis I completely get that. This issue was one of the reasons we added a more generic API function. We don't want people to have to worry about things like Authorization headers to do this. At the same time, there are a lot of ServiceNow APIs and it's daunting for us to try to track changes to every one of them. We were absolutely planning for this exact sort of thing to be possible with the changes to the Meanwhile, is it feasible for you to test with the main branch prior to the 2.5.0 release (which depends on some things, but I'd guess is weeks and certainly not months away)? |
@mhjacks You're wanting me to test the changes to api module using the |
@minsis Yes, if you're willing and able. |
@mhjacks I was able to test with the following: - hosts: localhost
connection: local
gather_facts: false
tasks:
- name: "Create Service Catalog Ticket"
servicenow.itsm.api:
action: "post"
api_path: "api/sn_sc/servicecatalog/items/{{ lookup('ansible.builtin.env', 'SYSID') }}/order_now"
data:
sysparm_quantity: 1
variables:
requested_for: "<redacted>"
requested_for_manager: "<redacted>"
request_type: "Add Account"
short_description: "Add user 1"
description: "Need to create an account for user 1"
email_address_hos: "<redacted>" {
"changed": true,
"diff": {
"after": {
"number": "<redacted>",
"parent_id": null,
"parent_table": "task",
"request_id": "<redacted>",
"request_number": "<redacted>",
"sys_id": "<redacted>",
"table": "sc_request"
},
"before": null
},
"invocation": {
"module_args": {
"action": "post",
"api_path": "api/sn_sc/servicecatalog/items/<redacted>/order_now",
"data": {
"sysparm_quantity": 1,
"variables": {
"description": "Need to create an account for user 1",
"email_address_hos": "<redacted>",
"request_type": "Add Account",
"requested_for": "<redacted>",
"requested_for_manager": "<redacted>",
"short_description": "Add user 1"
}
},
"instance": {
"access_token": null,
"api_path": "api/now",
"client_id": null,
"client_secret": null,
"custom_headers": null,
"grant_type": null,
"host": "<redacted>",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"refresh_token": null,
"timeout": null,
"username": "<redacted>",
"validate_certs": true
},
"query_params": {},
"resource": null,
"sys_id": null,
"template": null
}
},
"record": {
"number": "<redacted>",
"parent_id": null,
"parent_table": "task",
"request_id": "<redacted>",
"request_number": "<redacted>",
"sys_id": "<redacted>",
"table": "sc_request"
}
} However, there is some confusion as you can see in the output as well as the documentation. The newly added Obviously the module is ignoring |
@tupyy Could you please take a look? |
@minsis Thanks for trying this out. We'll investigate further |
Hello, |
@minsis Modules for service_catalog are available in the latest release |
SUMMARY
For the most part you can't really add records to sc_req and and sc_req_item tables without having the internal role, which you can't assign publicly anyways. It would be good to have a module that could create orders from the service catalog.
Since
servicenow.itsm.api
doesn't support anything outside of /now/table calls there's no good way to utilize this collection. #247 is asking to allow calls outside of /now/table, but since making a call to the service catalog api, there's a whole host of things that can be configured, so it might be better to have it as its own module.ISSUE TYPE
COMPONENT NAME
Having a module servicenow.itsm.service_catalog that would essentially making calls to the /sn_sc/servicecatalog/ API endpoint.
ADDITIONAL INFORMATION
This is just an example of a use case for a single order to submit to
api/sn_sc/servicecatalog/items/{sys_id}/order_now
, but other actions might be a good thing to, like adding to cart, checkout, etc.Currently I just use raw api, but it would be nice to utilize this collection since its all servicenow related, and features of this collection (like setting environment variables for username/password)
My current workaround:
The text was updated successfully, but these errors were encountered: