Skip to content

Commit

Permalink
Merge pull request #27 from opsgenie/fix-alert-responders
Browse files Browse the repository at this point in the history
Fix alert & incident responders
  • Loading branch information
mhamzak008 authored Nov 6, 2019
2 parents c2e9ef0 + affe339 commit 74dd84c
Show file tree
Hide file tree
Showing 21 changed files with 129 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 2.0.0
- Package version: 2.0.1
- Package version: 2.0.2
- Build package: com.atlassian.opsgenie.codegen.geniepy.GeniepyGenerator

For more information, please visit [https://www.opsgenie.com/contact-us](https://www.opsgenie.com/contact-us)
Expand Down
2 changes: 1 addition & 1 deletion docs/Alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Name | Type | Description | Notes
**source** | **str** | | [optional]
**owner** | **str** | | [optional]
**priority** | **str** | | [optional]
**responders** | [**list[Recipient]**](Recipient.md) | | [optional]
**responders** | [**list[Responder]**](Responder.md) | | [optional]
**integration** | [**AlertIntegration**](AlertIntegration.md) | | [optional]
**report** | [**AlertReport**](AlertReport.md) | | [optional]
**actions** | **list[str]** | | [optional]
Expand Down
2 changes: 1 addition & 1 deletion docs/BaseAlert.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Name | Type | Description | Notes
**source** | **str** | | [optional]
**owner** | **str** | | [optional]
**priority** | **str** | | [optional]
**responders** | [**list[Recipient]**](Recipient.md) | | [optional]
**responders** | [**list[Responder]**](Responder.md) | | [optional]
**integration** | [**AlertIntegration**](AlertIntegration.md) | | [optional]
**report** | [**AlertReport**](AlertReport.md) | | [optional]

Expand Down
2 changes: 1 addition & 1 deletion docs/BaseIncident.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Name | Type | Description | Notes
**source** | **str** | | [optional]
**owner** | **str** | | [optional]
**priority** | **str** | | [optional]
**responders** | [**list[Recipient]**](Recipient.md) | | [optional]
**responders** | [**list[Responder]**](Responder.md) | | [optional]
**team_id** | **str** | | [optional]
**details** | **dict(str, str)** | Map of key-value pairs to use as custom properties of the incident | [optional]

Expand Down
2 changes: 1 addition & 1 deletion docs/Incident.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Name | Type | Description | Notes
**source** | **str** | | [optional]
**owner** | **str** | | [optional]
**priority** | **str** | | [optional]
**responders** | [**list[Recipient]**](Recipient.md) | | [optional]
**responders** | [**list[Responder]**](Responder.md) | | [optional]
**team_id** | **str** | | [optional]
**details** | **dict(str, str)** | Map of key-value pairs to use as custom properties of the incident | [optional]
**request_id** | **str** | | [optional]
Expand Down
2 changes: 2 additions & 0 deletions docs/TeamResponder.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**type** | **str** | |
**id** | **str** | |
**name** | **str** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
3 changes: 2 additions & 1 deletion docs/UserResponder.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **str** | | [optional]
**type** | **str** | |
**id** | **str** | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
7 changes: 2 additions & 5 deletions opsgenie-oas.json
Original file line number Diff line number Diff line change
Expand Up @@ -4518,7 +4518,6 @@
"Responder": {
"x-opsgenie-domain": "common",
"type": "object",
"discriminator": "type",
"required": [
"type",
"id"
Expand All @@ -4538,7 +4537,6 @@
},
"UserResponder": {
"x-opsgenie-domain": "common",
"x-discriminator-value": "user",
"description": "User responder",
"allOf": [
{
Expand All @@ -4556,7 +4554,6 @@
},
"TeamResponder": {
"x-opsgenie-domain": "common",
"x-discriminator-value": "team",
"description": "Team responder",
"allOf": [
{
Expand Down Expand Up @@ -5294,7 +5291,7 @@
"responders": {
"type": "array",
"items": {
"$ref": "#/definitions/Recipient"
"$ref": "#/definitions/Responder"
}
},
"integration": {
Expand Down Expand Up @@ -6127,7 +6124,7 @@
"responders": {
"type": "array",
"items": {
"$ref": "#/definitions/Recipient"
"$ref": "#/definitions/Responder"
}
},
"teamId": {
Expand Down
8 changes: 2 additions & 6 deletions opsgenie-oas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9105,7 +9105,7 @@ components:
responders:
type: array
items:
$ref: '#/components/schemas/Recipient'
$ref: '#/components/schemas/Responder'
integration:
$ref: '#/components/schemas/AlertIntegration'
report:
Expand Down Expand Up @@ -9217,8 +9217,6 @@ components:
- team
id:
type: string
discriminator:
propertyName: type
x-opsgenie-domain: common
AssignAlertPayload:
allOf:
Expand All @@ -9239,7 +9237,6 @@ components:
id:
type: string
x-opsgenie-domain: common
x-discriminator-value: user
AddTagsToAlertPayload:
allOf:
- $ref: '#/components/schemas/AlertActionPayload'
Expand Down Expand Up @@ -9315,7 +9312,7 @@ components:
responders:
type: array
items:
$ref: '#/components/schemas/Recipient'
$ref: '#/components/schemas/Responder'
teamId:
type: string
details:
Expand All @@ -9337,7 +9334,6 @@ components:
name:
type: string
x-opsgenie-domain: common
x-discriminator-value: team
WeekdayTimeRestrictionInterval:
description: Weekday time restriction interval
allOf:
Expand Down
2 changes: 1 addition & 1 deletion opsgenie_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
from opsgenie_sdk.models.weekday_time_restriction_interval import WeekdayTimeRestrictionInterval
from opsgenie_sdk.models.weekday_time_restriction_interval_all_of import WeekdayTimeRestrictionIntervalAllOf

__version__ = "2.0.1"
__version__ = "2.0.2"

# import apis into sdk package

Expand Down
6 changes: 3 additions & 3 deletions opsgenie_sdk/api/alert/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Alert(object):
'source': 'str',
'owner': 'str',
'priority': 'str',
'responders': 'list[Recipient]',
'responders': 'list[Responder]',
'integration': 'AlertIntegration',
'report': 'AlertReport',
'actions': 'list[str]',
Expand Down Expand Up @@ -527,7 +527,7 @@ def responders(self):
:return: The responders of this Alert. # noqa: E501
:rtype: list[Recipient]
:rtype: list[Responder]
"""
return self._responders

Expand All @@ -537,7 +537,7 @@ def responders(self, responders):
:param responders: The responders of this Alert. # noqa: E501
:type: list[Recipient]
:type: list[Responder]
"""

self._responders = responders
Expand Down
6 changes: 3 additions & 3 deletions opsgenie_sdk/api/alert/base_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BaseAlert(object):
'source': 'str',
'owner': 'str',
'priority': 'str',
'responders': 'list[Recipient]',
'responders': 'list[Responder]',
'integration': 'AlertIntegration',
'report': 'AlertReport'
}
Expand Down Expand Up @@ -507,7 +507,7 @@ def responders(self):
:return: The responders of this BaseAlert. # noqa: E501
:rtype: list[Recipient]
:rtype: list[Responder]
"""
return self._responders

Expand All @@ -517,7 +517,7 @@ def responders(self, responders):
:param responders: The responders of this BaseAlert. # noqa: E501
:type: list[Recipient]
:type: list[Responder]
"""

self._responders = responders
Expand Down
6 changes: 3 additions & 3 deletions opsgenie_sdk/api/incident/base_incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BaseIncident(object):
'source': 'str',
'owner': 'str',
'priority': 'str',
'responders': 'list[Recipient]',
'responders': 'list[Responder]',
'team_id': 'str',
'details': 'dict(str, str)'
}
Expand Down Expand Up @@ -351,7 +351,7 @@ def responders(self):
:return: The responders of this BaseIncident. # noqa: E501
:rtype: list[Recipient]
:rtype: list[Responder]
"""
return self._responders

Expand All @@ -361,7 +361,7 @@ def responders(self, responders):
:param responders: The responders of this BaseIncident. # noqa: E501
:type: list[Recipient]
:type: list[Responder]
"""

self._responders = responders
Expand Down
6 changes: 3 additions & 3 deletions opsgenie_sdk/api/incident/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Incident(object):
'source': 'str',
'owner': 'str',
'priority': 'str',
'responders': 'list[Recipient]',
'responders': 'list[Responder]',
'team_id': 'str',
'details': 'dict(str, str)',
'request_id': 'str'
Expand Down Expand Up @@ -356,7 +356,7 @@ def responders(self):
:return: The responders of this Incident. # noqa: E501
:rtype: list[Recipient]
:rtype: list[Responder]
"""
return self._responders

Expand All @@ -366,7 +366,7 @@ def responders(self, responders):
:param responders: The responders of this Incident. # noqa: E501
:type: list[Recipient]
:type: list[Responder]
"""

self._responders = responders
Expand Down
2 changes: 1 addition & 1 deletion opsgenie_sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'opsgenie-sdk-python-2.0.1'
self.user_agent = 'opsgenie-sdk-python-2.0.2'

# init metric publishers
self.http_metric_publisher = self.rest_client.http_metric
Expand Down
2 changes: 1 addition & 1 deletion opsgenie_sdk/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def to_debug_report(self):
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 2.0.0\n"\
"SDK Package Version: 2.0.1".\
"SDK Package Version: 2.0.2".\
format(env=sys.platform, pyversion=sys.version)

def get_host_settings(self):
Expand Down
13 changes: 1 addition & 12 deletions opsgenie_sdk/models/responder.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,12 @@ class Responder(object):
'id': 'id'
}

discriminator_value_class_map = {
'user': 'UserResponder',
'team': 'TeamResponder'
}

def __init__(self, type=None, id=None): # noqa: E501
"""Responder - a model defined in OpenAPI""" # noqa: E501

self._type = None
self._id = None
self.discriminator = 'type'
self.discriminator = None

self.type = type
self.id = id
Expand Down Expand Up @@ -108,12 +103,6 @@ def id(self, id):

self._id = id

def get_real_child_model(self, data):
"""Returns the real base class specified by the discriminator"""
discriminator_key = self.attribute_map[self.discriminator]
discriminator_value = data[discriminator_key]
return self.discriminator_value_class_map.get(discriminator_value)

def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
Expand Down
62 changes: 61 additions & 1 deletion opsgenie_sdk/models/team_responder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,82 @@ class TeamResponder(object):
and the value is json key in definition.
"""
openapi_types = {
'type': 'str',
'id': 'str',
'name': 'str'
}

attribute_map = {
'type': 'type',
'id': 'id',
'name': 'name'
}

def __init__(self, name=None): # noqa: E501
def __init__(self, type=None, id=None, name=None): # noqa: E501
"""TeamResponder - a model defined in OpenAPI""" # noqa: E501

self._type = None
self._id = None
self._name = None
self.discriminator = None

self.type = type
self.id = id
if name is not None:
self.name = name

@property
def type(self):
"""Gets the type of this TeamResponder. # noqa: E501
:return: The type of this TeamResponder. # noqa: E501
:rtype: str
"""
return self._type

@type.setter
def type(self, type):
"""Sets the type of this TeamResponder.
:param type: The type of this TeamResponder. # noqa: E501
:type: str
"""
if type is None:
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
allowed_values = ["user", "team"] # noqa: E501
if type not in allowed_values:
raise ValueError(
"Invalid value for `type` ({0}), must be one of {1}" # noqa: E501
.format(type, allowed_values)
)

self._type = type

@property
def id(self):
"""Gets the id of this TeamResponder. # noqa: E501
:return: The id of this TeamResponder. # noqa: E501
:rtype: str
"""
return self._id

@id.setter
def id(self, id):
"""Sets the id of this TeamResponder.
:param id: The id of this TeamResponder. # noqa: E501
:type: str
"""
if id is None:
raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501

self._id = id

@property
def name(self):
"""Gets the name of this TeamResponder. # noqa: E501
Expand Down
Loading

0 comments on commit 74dd84c

Please sign in to comment.