Python API for ServiceNow

ServiceNow, updated 🕥 2023-02-14 07:42:35

ServiceNow Python API

What: PySnc is a python interface for the ServiceNow and the Table API. It is designed to mimic the familiar GlideRecord interface you know with pythonic support where applicable.

Why: Spawned from the desire to interact with ServiceNow data in a familiar and consistent manner

Install

pip install pysnc

Quick Start

```python from pysnc import ServiceNowClient

client = ServiceNowClient('https://dev0000.service-now.com', ('integration.user', password))

gr = client.GlideRecord('sys_user') gr.add_query('user_name', 'admin') gr.query() for r in gr: print(r.sys_id)

```

Or you can more traditionally:

while gr.next(): print(gr.sys_id);

It is recommended you use OAuth, however:

```python from pysnc import ServiceNowClient, ServiceNowOAuth2

client = ServiceNowClient('dev0000', ServiceNowOAuth2('integration.user', password)) ```

Documentation

Full documentation currently available at https://servicenow.github.io/PySNC/

Or build them yourself:

cd docs && make html

Development Notes

The following functions are not (yet?) supported:

  • choose_window(first_row, last_row, force_count=True) TODO
  • get_class_display_value()
  • get_record_class_name()
  • get_unique_value()
  • is_valid() TODO
  • is_valid_record()
  • new_record()
  • update_multiple() TODO
  • _next()
  • _query()

The following will not be implemented:

  • get_attribute(field_name) Not Applicable
  • get_ED() Not Applicable
  • get_label() Not Applicable
  • get_last_error_message() Not Applicable
  • set_workflow(enable) Not Possible
  • operation() Not Applicable
  • set_abort_action() Not Applicable
  • is_valid_field() Not Possible
  • is_action_aborted() Not Applicable

Further Reading

See the documentation.

Feature Wants and TODO

  • GlideAggregate support (/api/now/stats/{tableName})

And we want to:

  • Improve documentation
  • Refactor session abstraction
  • Improve Attachment OO

Issues

#56 make pop record keep a client reference

opened on 2023-02-14 07:42:34 by vetsin

for #56

convert to poetry from pipenv

opened on 2023-02-14 07:13:49 by vetsin

setup.py is a clunker and poetry just makes more sense than pipenv

inconsistent get behavior

opened on 2023-02-08 16:20:53 by vetsin

When doing something as such:

python gr = client.GlideRecord(table) gr.initialize() gr.field = 'some value' gr.get('non_existant_id')

We expect the gr.field to now be None -- in actuality it is still some value as the failed get() did not update _current.

Actual GlideRecord behaves in this matter:

javascript let gr = new GlideRecord('incident') gr.initialize() gr.short_description = 'this is a test' gs.info(gr.short_description) gr.get('sys_id') gs.info(gr.short_description)

will give us

my_scope: this is a test my_scope:

Bump cryptography from 38.0.1 to 39.0.1

opened on 2023-02-08 04:19:14 by dependabot[bot]

Bumps cryptography from 38.0.1 to 39.0.1.

Changelog

Sourced from cryptography's changelog.

39.0.1 - 2023-02-07


* **SECURITY ISSUE** - Fixed a bug where ``Cipher.update_into`` accepted Python
  buffer protocol objects, but allowed immutable buffers. **CVE-2023-23931**
* Updated Windows, macOS, and Linux wheels to be compiled with OpenSSL 3.0.8.

.. _v39-0-0:

39.0.0 - 2023-01-01

  • BACKWARDS INCOMPATIBLE: Support for OpenSSL 1.1.0 has been removed. Users on older version of OpenSSL will need to upgrade.
  • BACKWARDS INCOMPATIBLE: Dropped support for LibreSSL < 3.5. The new minimum LibreSSL version is 3.5.0. Going forward our policy is to support versions of LibreSSL that are available in versions of OpenBSD that are still receiving security support.
  • BACKWARDS INCOMPATIBLE: Removed the encode_point and from_encoded_point methods on :class:~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicNumbers, which had been deprecated for several years. :meth:~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey.public_bytes and :meth:~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey.from_encoded_point should be used instead.
  • BACKWARDS INCOMPATIBLE: Support for using MD5 or SHA1 in :class:~cryptography.x509.CertificateBuilder, other X.509 builders, and PKCS7 has been removed.
  • BACKWARDS INCOMPATIBLE: Dropped support for macOS 10.10 and 10.11, macOS users must upgrade to 10.12 or newer.
  • ANNOUNCEMENT: The next version of cryptography (40.0) will change the way we link OpenSSL. This will only impact users who build cryptography from source (i.e., not from a wheel), and specify their own version of OpenSSL. For those users, the CFLAGS, LDFLAGS, INCLUDE, LIB, and CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS environment variables will no longer be respected. Instead, users will need to configure their builds as documented here_.
  • Added support for :ref:disabling the legacy provider in OpenSSL 3.0.x<legacy-provider>.
  • Added support for disabling RSA key validation checks when loading RSA keys via :func:~cryptography.hazmat.primitives.serialization.load_pem_private_key, :func:~cryptography.hazmat.primitives.serialization.load_der_private_key, and :meth:~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateNumbers.private_key. This speeds up key loading but is :term:unsafe if you are loading potentially attacker supplied keys.
  • Significantly improved performance for :class:~cryptography.hazmat.primitives.ciphers.aead.ChaCha20Poly1305

... (truncated)

Commits


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/ServiceNow/PySNC/network/alerts).

Bump oauthlib from 3.2.1 to 3.2.2

opened on 2023-02-06 22:18:34 by dependabot[bot]

Bumps oauthlib from 3.2.1 to 3.2.2.

Release notes

Sourced from oauthlib's releases.

3.2.2

OAuth2.0 Provider:

  • CVE-2022-36087
Changelog

Sourced from oauthlib's changelog.

3.2.2 (2022-10-17)

OAuth2.0 Provider:

  • CVE-2022-36087
Commits
  • e6c33e4 Add 3.2.2 version
  • 4a4d65f Merge pull request #832 from oauthlib/3.2.1
  • 2e40b41 Merge pull request from GHSA-3pgj-pg6c-r5p7
  • b4bdd09 Merge pull request #818 from dasm/master
  • 5d85c61 Fix IPV6 regex used to check redirect_uri
  • e514826 Add check of performance of ipv6 check
  • 9aa45aa Restored test for port 0.
  • f52f641 Merge branch 'oauthlib:master' into master
  • ed0cb63 Removed unused query and fragment
  • d05c388 Removed dependency on split
  • Additional commits viewable in compare view


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/ServiceNow/PySNC/network/alerts).

AttributeError: 'NoneType' object has no attribute '_put'

opened on 2022-12-22 15:32:02 by arthurzenika

When using record = gr.pop_record() to extract and item, if I try to modify it and then update it record.update(), it fails with

AttributeError: 'NoneType' object has no attribute '_put'

Releases

1.0.7 2022-09-29 19:10:39

  • gh actions
  • up default batch size for performance reasons
  • improve attachment file handling (reading, mostly)
  • improve documentation
  • added jwt support

1.0.5 2022-03-21 19:11:26

  • Correctly implemented batching - if queries are slow up the default batch size.

1.0.4 2021-04-22 22:25:15

Release

1.0.3 2020-08-05 19:19:34

1.0.2 2020-07-16 18:13:50

The 1.0.2 release

ServiceNow

Works for you™

GitHub Repository