Coder Social home page Coder Social logo

django-snow's Introduction

DEPRECATED

No Maintenance Intended

Latest Version

Test/build status

Code coverage

django-snow is a django app to manage ServiceNow tickets from within a django project.

This project is no longer maintained, and is welcoming new maintainers. If you would like to take over development of this project, please contact [email protected].

Installation

pip install django-snow

Configuration

django-snow requires the following settings to be set in your Django settings:

  • SNOW_INSTANCE - The ServiceNow instance where the tickets should be created
  • SNOW_API_USER - The ServiceNow API User
  • SNOW_API_PASS - The ServiceNow API User's Password
  • SNOW_ASSIGNMENT_GROUP (Optional) - The group to which the tickets should be assigned. If this is not provided, each call to create the tickets should be provided with an assignment_group argument. See the API documentation for more details
  • SNOW_DEFAULT_CHANGE_TYPE (Optional) - Default Change Request Type. If not provided, standard will considered as the default type.

Usage

Creation

ChangeRequestHandler.create_change_request has the following parameters and return value:

Parameters

  • title - The title of the change request
  • description - The description of the change request
  • assignment_group - The group to which the change request is to be assigned. This is optional if SNOW_ASSIGNMENT_GROUP django settings is available, else, it is mandatory
  • payload (Optional) - The payload for creating the Change Request.

Returns

ChangeRequest model - The model created from the created Change Order.

Example

from django_snow.helpers import ChangeRequestHandler

def change_data(self):
    co_handler = ChangeRequestHandler()
    change_request = co_handler.create_change_request('Title', 'Description', 'assignment_group')

Updating

ChangeRequestHandler.update_change_request method signature:

Parameters

  • change_request - The ChangeRequest Model
  • payload - The payload to pass to the ServiceNow REST API.

Example

from django_snow.models import ChangeRequest
from django_snow.helpers import ChangeRequestHandler

def change_data(self):
    change_request = ChangeRequest.objects.filter(...)
    co_handler = ChangeRequestHandler()

    payload = {
                'description': 'updated description',
                'state': ChangeRequest.TICKET_STATE_IN_PROGRESS
              }

    co_handler.update_change_request(change_request, payload)

Closing

ChangeRequestHandler.close_change_request has the following signature:

Parameters

  • change_request - The ChangeRequest Model representing the Change Order to be closed.

Example

from django_snow.models import ChangeRequest
from django_snow.helpers import ChangeRequestHandler

def change_data(self):
    change_request = ChangeRequest.objects.filter(...)
    co_handler = ChangeRequestHandler()

    co_handler.close_change_request(change_request)

Closing with error

ChangeRequestHandler.close_change_request_with_error method signature:

Parameters

  • change_request - The ChangeRequest Model representing the Change Order to be closed with error
  • payload - The payload to pass to the ServiceNow REST API.

Example

from django_snow.models import ChangeRequest
from django_snow.helpers import ChangeRequestHandler

def change_data(self):
    change_request = ChangeRequest.objects.filter(...)
    co_handler = ChangeRequestHandler()

    payload = {
                'description': 'updated description',
                'title': 'foo'
              }

    co_handler.close_change_request_with_error(change_request, payload)

Models

ChangeRequest

The ChangeRequest model has the following attributes:

  • sys_id - The sys_id of the Change Request.
  • number - Change Request Number.
  • title - The title of the Change Request a.k.a short_description.
  • description - Description for the change request
  • assignment_group_guid - The GUID of the group to which the Change Request is assigned to
  • state - The State of the Change Request. Can be any one of the following ChangeRequest's constants:
    • TICKET_STATE_OPEN - '1'
    • TICKET_STATE_IN_PROGRESS - '2'
    • TICKET_STATE_COMPLETE - '3'
    • TICKET_STATE_COMPLETE_WITH_ERRORS - '4'

Supported Ticket Types

  • Change Requests

django-snow's People

Contributors

jjmanzer-godaddy avatar jwilhelm-godaddy avatar pradeepsixer avatar rmohan-godaddy avatar tarkatronic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-snow's Issues

migration 003 missing

Describe the bug
when running the manage.py command I get the following

Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

When i make the missing migration I find that it is for django_snow.

To Reproduce
Steps to reproduce the behavior:

  1. Go to shell
  2. run python manage.py migrate
  3. observe mention of missing migration

Expected behavior
0003 migration should be present

ambiguous exception needs to be more specific

Describe the bug
When an assignment_group is provided to create_change_request() that is invalid, we get an unclear message back leaving the user (and dev) unsure of what to do.

To Reproduce
Steps to reproduce the behavior:

change_order = ChangeRequestHandler().create_change_request(
    co_title,
    co_description,
    assignment_group="bad_assignment_group",
    payload=payload
)

Expected behavior
A clear and concise message like "your assignment_group XXX does not exist".

Additional context
Exception text

Traceback (most recent call last):
File "/usr/local/share/thor_api/.venv/lib/python3.6/site-packages/pysnow/response.py", line 173, in one
result = next(r)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/share/thor_api/.venv/lib/python3.6/site-packages/celery/app/trace.py", line 382, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/share/thor_api/.venv/lib/python3.6/site-packages/newrelic/hooks/application_celery.py", line 85, in wrapper
return wrapped(*args, **kwargs)
File "/usr/local/share/thor_api/.venv/lib/python3.6/site-packages/celery/app/trace.py", line 641, in __protected_call__
return self.run(*args, **kwargs)
File "/usr/local/share/thor_api/netexec/tasks.py", line 59, in execute_request
request_handler.run()
File "/usr/local/share/thor_api/netexec/handlers/base.py", line 58, in run
if self.create_automated_change_order():
File "/usr/local/share/thor_api/netexec/handlers/base.py", line 109, in create_automated_change_order
payload=payload
File "/usr/local/share/thor_api/.venv/lib/python3.6/site-packages/django_snow/helpers/snow_request_handler.py", line 47, in create_change_request
payload['assignment_group'] = self.get_snow_group_guid(assignment_group or self.snow_assignment_group)
File "/usr/local/share/thor_api/.venv/lib/python3.6/site-packages/django_snow/helpers/snow_request_handler.py", line 147, in get_snow_group_guid
result = response.one()
File "/usr/local/share/thor_api/.venv/lib/python3.6/site-packages/pysnow/response.py", line 175, in one
raise NoResults("No records found")
pysnow.exceptions.NoResults: No records found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.