Skip to content

Commit

Permalink
Merge pull request #5 from rapid7/fix_outage_handling
Browse files Browse the repository at this point in the history
Fix outage handling
  • Loading branch information
jschipp-r7 authored Apr 3, 2020
2 parents ccc5a50 + 73bc2c7 commit af890ea
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 39 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
types: [python]
language_version: python3.7
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ disttest: package
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*

distprod: package
python3 -m twine upload dist/*
python3 -m twine upload dist/*

clean:
rm -rf .pytest_cache/ dist/ *.egg-info/
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

# GitHub Status Checker

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
![Tests](https://github.com/rapid7/github-status-checker/workflows/Tests/badge.svg)
![Python Lint](https://github.com/rapid7/github-status-checker/workflows/Python%20Lint/badge.svg)
![Markdown Lint](https://github.com/rapid7/github-status-checker/workflows/Markdown%20Lint/badge.svg)

## What this is

A tool and Python module for checking the status of GitHub.
Expand All @@ -21,8 +27,18 @@ moose@rapid7:~$ github-status webhooks
Service 'Webhooks' is currently operational!
```

## Contributions

Contributions are welcome! This project utilizes [black](https://github.com/psf/black)
and [pre-commit](https://pre-commit.com/) for handling code
style. Simply follow the instructions for installing pre-commit and
run `pre-commit install` in the repository after cloning and you will
be on your way to contributing!

## Changelog

* 1.0.2 - Update to handle crash on outage report | Code style: black
| Add contribution section
* 1.0.1 - Update homepage and author name
* 1.0.0 - Swap dataclasses for traditional classes for greater Python version
compatibility (Python 3.x+)
Expand Down
10 changes: 10 additions & 0 deletions github_status_checker/models/affected_component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AffectedComponent:
def __init__(self, code: str, name: str, old_status: str, new_status: str):
self.code = code
self.name = name
self.old_status = old_status
self.new_status = new_status

@classmethod
def from_json(cls, json_: dict):
return cls(**json_)
37 changes: 22 additions & 15 deletions github_status_checker/models/incident.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
from typing import Optional

from github_status_checker.models.incident_update import IncidentUpdate
from github_status_checker.models.component import Component


class Incident:

def __init__(self,
created_at: str,
id: str,
impact: str,
incident_updates: [IncidentUpdate],
monitoring_at: Optional[str],
name: str,
page_id: str,
resolved_at: Optional[str],
shortlink: str,
status: str,
updated_at: str):
def __init__(
self,
created_at: str,
id: str,
impact: str,
incident_updates: [IncidentUpdate],
components: [Component],
monitoring_at: Optional[str],
name: str,
page_id: str,
resolved_at: Optional[str],
shortlink: str,
status: str,
started_at: str,
updated_at: str,
):
self.created_at = created_at
self.id = id
self.impact = impact
self.incident_updates = incident_updates
self.components = components
self.monitoring_at = monitoring_at
self.name = name
self.page_id = page_id
self.resolved_at = resolved_at
self.shortlink = shortlink
self.status = status
self.started_at = started_at
self.updated_at = updated_at

@classmethod
def from_json(cls, json_: dict):
incident = cls(**json_)
incident.incident_updates = \
[IncidentUpdate.from_json(json_=iu) for iu in json_.get("incident_updates")]
incident.incident_updates = [
IncidentUpdate.from_json(json_=iu) for iu in json_.get("incident_updates")
]

return incident
29 changes: 21 additions & 8 deletions github_status_checker/models/incident_update.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from github_status_checker.models.affected_component import AffectedComponent


class IncidentUpdate:
body: str
created_at: str
Expand All @@ -7,18 +10,28 @@ class IncidentUpdate:
status: str
updated_at: str

def __init__(self,
body: str,
created_at: str,
display_at: str,
id: str,
incident_id: str,
status: str,
updated_at: str):
def __init__(
self,
body: str,
created_at: str,
display_at: str,
affected_components: [AffectedComponent],
deliver_notifications: bool,
custom_tweet: str,
tweet_id: str,
id: str,
incident_id: str,
status: str,
updated_at: str,
):

self.body = body
self.created_at = created_at
self.display_at = display_at
self.affected_components = affected_components
self.deliver_notifications = deliver_notifications
self.custom_tweet = custom_tweet
self.tweet_id = str(tweet_id)
self.id = id
self.incident_id = incident_id
self.status = status
Expand Down
22 changes: 9 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@

setup(
name="github_status_checker",
version="1.0.1",
version="1.0.2",
description="Python module/tool for checking the status of GitHub.",
long_description=long_description,
long_description_content_type="text/markdown",
author='Rapid7 Integration Alliance',
author_email='[email protected]',
url='https://github.com/rapid7/github-status-checker',
license='MIT',
author="Rapid7 Integration Alliance",
author_email="[email protected]",
url="https://github.com/rapid7/github-status-checker",
license="MIT",
packages=find_packages(),
install_requires=[
"requests~=2.0"
],
install_requires=["requests~=2.0"],
include_package_data=True,
entry_points={
'console_scripts': [
'github-status=github_status_checker.__main__:main'
]
"console_scripts": ["github-status=github_status_checker.__main__:main"]
},
classifiers=[
"Programming Language :: Python :: 3",
Expand All @@ -34,6 +30,6 @@
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Version Control :: Git",
"Topic :: System :: Networking :: Monitoring"
],
"Topic :: System :: Networking :: Monitoring",
],
)
Loading

0 comments on commit af890ea

Please sign in to comment.