Git Product home page Git Product logo

django_service_registry's Introduction

A Service Registry using Django

Overview

A solution using Django and the Django REST Framework to demo the Service Registry API. This Service Registry API provides endpoints for creating, finding, deleting, and updating services in the registry.

Installation

- Ensure that you are running in a Python3 environment.
- pip install -r requirements.txt

Running the Django development server

$ python manage.py runserver

URL format

All endpoints are prefixed by /services/<api_version_number>. For example to find information about a service:

GET /services/v1/<name>

Testing

Django REST framework allows the API to be browsed. Simply point your browser at http://127.0.0.1:8000/services/v1 to get started.

There are unit and BDD tests that can be run as shown below:

$ python manage.py test
$ python manage.py behave

In addition, you can test the API from the command line using cURL. This allows you to easily investigate and test the service as shown in the examples below.

Add a service

$ curl -i -H "Content-Type: application/json" -X POST -d '{"service":"test1","version":"0.0.1"}' http://localhost:8000/services/v1

Returns:

{
  "service": "test1", 
  "version": "0.0.1", 
  "change": "created" 
}

Find a service

$ curl -i http://localhost:8000/services/v1/test1

Returns: (if we have added test1 twice)

{
  "service":"test1",
  "count":2
}

Delete a service

$ curl -i -H "Content-Type: application/json" -X DELETE http://localhost:8000/services/v1/test1

Returns:

{
  "change":"removed",
  "service":"test1"
}

Update a service

$ curl -i -H "Content-Type: application/json" -X PUT -d '{"service":"test99","version":"1.1.1"}' http://localhost:8000/services/v1/1  

Returns:

{
  "change":"changed"
}

List all registered services (N.B. not in the reqs. for development only)

$ curl -i http://localhost:8000/services/v1

Returns:

[
  {
    "service":"updatetest",
    "version":"9.0.1"
  },
  {
    "service":"test",
    "version":"0.0.1"
  },
  {
    "service":"test",
    "version":"0.0.1"
  }
]

TODO

- Improve tests
- Improve input validation and error handling
- Add logging
- Add authentication and authorisation 
- Run over TLS 
- Improve commenting
- Add some mechanism for reporting and checking health of services
- Add additional fields such as the URL of the service
- Add rate limiting
- Remove unnecessary modules from requirements.txt
- Update validators

django_service_registry's People

Contributors

philratcliffe avatar

Watchers

 avatar  avatar

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.