-
Notifications
You must be signed in to change notification settings - Fork 21
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
ServiceNow Pack Update #16
base: master
Are you sure you want to change the base?
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_api
isintroduced. 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-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.