ServiceNow Pack Update#16
Conversation
Proposed Revision Number: 0.5.0 Objective: Update to pack to prevent deprecation warnings from use of the old style API calls by replacing them with the [PySNow](https://pysnow.readthedocs.io/) library [Resource](https://pysnow.readthedocs.io/en/latest/api/resource.html) APIs. Scope: This update applies to the following *actions* of the [Stackstorm ServiceNow pack](https://github.com/StackStorm-Exchange/stackstorm-servicenow): * get * create * update * delete None of the "custom" methods were updated. Approach/Implementation: A new pack-level (in `config.schema.yaml`) boolean configuration flag named `use_new_service_now_api` is introduced. When enabled (checked), a new code block in each of the specified actions above is executed that uses the Resource APIs. Otherwise, the existing module code is used. In addition, the `get` module/method includes one new _optional_ *array* (list) parameter: `fields`. This parameter accepts a comma-separated list of field names for the specified ServiceNow table and returns only those fields in the response (result set) for each record. Note: This attribute applies *ONLY* to the new API.
…self.config['use_new_service_now_api']' from CI/CD errors.
amanda11
left a comment
There was a problem hiding this comment.
Thanks for the update. I've added a couple of comments, but also pack.yaml when I view it in the PR is showing as empty now - so can you check if something has gone funny on the upload?
| # If using new ServiceNew API... | ||
| if self.config['use_new_service_now_api']: | ||
| client = self.client | ||
| resource = client.resource(api_path="/table/{0}".format(table)) |
There was a problem hiding this comment.
Might be nicer to use python fstrings instead of format strings now that we are python 3 only, e.g. api_path=f"/table/{table}" for simplicity, but not essential. Applies to other places as well.
There was a problem hiding this comment.
Thanks, Amanda! This is a good suggestion; I'll keep this in mind in the future. I'm a little set in my ways about format() and adjusting to fstrings. :)
|
Tim Jones seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Co-authored-by: Amanda McGuinness <amanda.mcguinness@ammeon.com>
|
@jamesdreid @TimothyDJones It looks like one of the commits is associated with user "Tim Jones" rather than "TimothyDJones" - so this means we get an error as only TimothyDJones has signed the CLA. |
amanda11
left a comment
There was a problem hiding this comment.
There is a problem with the pack.yaml change, as its not coming up in the PR.
We need a pack.yaml with version 1.5.0 in, and then I think this can be merged.
For some reason it comes up as a blank file, as it looks like its associated with a fork that isn't quite linked properly to the PR.
Proposed Revision Number: 0.5.0
Objective: Update to pack to prevent deprecation warnings from use of
the old style API calls by replacing them with the
PySNow library
Resource
APIs.
Scope: This update applies to the following actions of the Stackstorm
ServiceNow
pack:
None of the "custom" methods were updated.
Approach/Implementation: A new pack-level (in
config.schema.yaml)boolean configuration flag named
use_new_service_now_apiisintroduced. When enabled (checked), a new code block in each of the
specified actions above is executed that uses the Resource APIs.
Otherwise, the existing module code is used.
In addition, the
getmodule/method includes one new optional array(list) parameter:
fields. This parameter accepts a comma-separatedlist of field names for the specified ServiceNow table and returns only
those fields in the response (result set) for each record. Note: This
attribute applies ONLY to the new API.