relay-python-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- relay_python/__init__.py +14 -0
- relay_python/_http.py +50 -0
- relay_python/client.py +136 -0
- relay_python/exceptions.py +69 -0
- relay_python/models.py +79 -0
- relay_python_sdk-0.1.0.dist-info/METADATA +27 -0
- relay_python_sdk-0.1.0.dist-info/RECORD +9 -0
- relay_python_sdk-0.1.0.dist-info/WHEEL +4 -0
- relay_python_sdk-0.1.0.dist-info/licenses/LICENSE +202 -0
relay_python/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Official Python SDK for Relay."""
|
|
2
|
+
from .client import Relay
|
|
3
|
+
from .exceptions import (
|
|
4
|
+
AuthenticationError,
|
|
5
|
+
NotFoundError,
|
|
6
|
+
RateLimitError,
|
|
7
|
+
RelayError,
|
|
8
|
+
ServerError,
|
|
9
|
+
ValidationError,
|
|
10
|
+
)
|
|
11
|
+
from .models import Delivery, Endpoint, Event
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.0"
|
|
14
|
+
__all__ = ["Relay", "Event", "Endpoint", "Delivery", "RelayError", "AuthenticationError", "NotFoundError", "ValidationError", "RateLimitError", "ServerError"]
|
relay_python/_http.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Internal HTTP transport."""
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from .exceptions import _raise_for_status
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class HttpTransport:
|
|
10
|
+
"""Thin wrapper over httpx.Client with error mapping."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, base_url: str, api_key: str, timeout: float) -> None:
|
|
13
|
+
self._client = httpx.Client(
|
|
14
|
+
base_url=base_url.rstrip("/"),
|
|
15
|
+
headers={
|
|
16
|
+
"Authorization": f"Bearer {api_key}",
|
|
17
|
+
"User-Agent": "relay-python/0.1.0",
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
},
|
|
20
|
+
timeout=timeout,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
def close(self) -> None:
|
|
24
|
+
self._client.close()
|
|
25
|
+
|
|
26
|
+
def request(
|
|
27
|
+
self,
|
|
28
|
+
method: str,
|
|
29
|
+
path: str,
|
|
30
|
+
*,
|
|
31
|
+
json: Any = None,
|
|
32
|
+
headers: dict[str, str] | None = None,
|
|
33
|
+
) -> dict[str, Any]:
|
|
34
|
+
resp = self._client.request(method, path, json=json, headers=headers)
|
|
35
|
+
body: dict[str, Any] = {}
|
|
36
|
+
if resp.content:
|
|
37
|
+
try:
|
|
38
|
+
body = resp.json()
|
|
39
|
+
except ValueError:
|
|
40
|
+
body = {}
|
|
41
|
+
code = body.get("code") if isinstance(body, dict) else None
|
|
42
|
+
message = body.get("error") or resp.text or resp.reason_phrase
|
|
43
|
+
_raise_for_status(resp.status_code, code, message)
|
|
44
|
+
return body
|
|
45
|
+
|
|
46
|
+
def __enter__(self) -> "HttpTransport":
|
|
47
|
+
return self
|
|
48
|
+
|
|
49
|
+
def __exit__(self, *args: Any) -> None:
|
|
50
|
+
self.close()
|
relay_python/client.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""Main Relay SDK client."""
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from . import exceptions
|
|
5
|
+
from ._http import HttpTransport
|
|
6
|
+
from .models import Delivery, Endpoint
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Relay:
|
|
10
|
+
"""Client for the Relay webhook delivery API.
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
>>> client = Relay(api_key="...", base_url="http://localhost:8080")
|
|
14
|
+
>>> event = client.send_event(
|
|
15
|
+
... source="stripe",
|
|
16
|
+
... event_type="payment.completed",
|
|
17
|
+
... data={"amount": 5000},
|
|
18
|
+
... idempotency_key="order-123",
|
|
19
|
+
... )
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
api_key: str,
|
|
25
|
+
*,
|
|
26
|
+
base_url: str = "http://localhost:8080",
|
|
27
|
+
timeout: float = 30.0,
|
|
28
|
+
) -> None:
|
|
29
|
+
if not api_key:
|
|
30
|
+
raise exceptions.AuthenticationError(
|
|
31
|
+
"api_key must be provided", status=401
|
|
32
|
+
)
|
|
33
|
+
self._http = HttpTransport(base_url, api_key, timeout)
|
|
34
|
+
|
|
35
|
+
# ============ Events ============
|
|
36
|
+
|
|
37
|
+
def send_event(
|
|
38
|
+
self,
|
|
39
|
+
*,
|
|
40
|
+
source: str,
|
|
41
|
+
event_type: str,
|
|
42
|
+
data: dict[str, Any],
|
|
43
|
+
idempotency_key: str | None = None,
|
|
44
|
+
) -> dict[str, Any]:
|
|
45
|
+
"""Submit an event for delivery."""
|
|
46
|
+
headers: dict[str, str] = {}
|
|
47
|
+
if idempotency_key:
|
|
48
|
+
headers["Idempotency-Key"] = idempotency_key
|
|
49
|
+
return self._http.request(
|
|
50
|
+
"POST",
|
|
51
|
+
"/v1/events",
|
|
52
|
+
json={"source": source, "event_type": event_type, "data": data},
|
|
53
|
+
headers=headers,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def replay_event(self, event_id: str) -> dict[str, Any]:
|
|
57
|
+
"""Replay a previously failed event."""
|
|
58
|
+
return self._http.request("POST", f"/v1/events/{event_id}/replay")
|
|
59
|
+
|
|
60
|
+
def get_deliveries(self, event_id: str) -> list[Delivery]:
|
|
61
|
+
"""Get all delivery attempts for an event."""
|
|
62
|
+
body = self._http.request("GET", f"/v1/events/{event_id}/deliveries")
|
|
63
|
+
items = body.get("deliveries") or body.get("items") or []
|
|
64
|
+
return [Delivery.from_dict(d) for d in items]
|
|
65
|
+
|
|
66
|
+
def get_attempts(self, event_id: str) -> list[dict[str, Any]]:
|
|
67
|
+
"""Get detailed attempt history for an event."""
|
|
68
|
+
body = self._http.request("GET", f"/v1/events/{event_id}/attempts")
|
|
69
|
+
attempts: list[dict[str, Any]] = body.get("attempts", [])
|
|
70
|
+
return attempts
|
|
71
|
+
|
|
72
|
+
# ============ Endpoints ============
|
|
73
|
+
|
|
74
|
+
def list_endpoints(self) -> list[Endpoint]:
|
|
75
|
+
"""List all registered webhook endpoints."""
|
|
76
|
+
body = self._http.request("GET", "/v1/endpoints")
|
|
77
|
+
items = body.get("endpoints") or body.get("items") or []
|
|
78
|
+
return [Endpoint.from_dict(e) for e in items]
|
|
79
|
+
|
|
80
|
+
def get_endpoint(self, endpoint_id: str) -> Endpoint:
|
|
81
|
+
"""Get a single endpoint by ID."""
|
|
82
|
+
body = self._http.request("GET", f"/v1/endpoints/{endpoint_id}")
|
|
83
|
+
return Endpoint.from_dict(body)
|
|
84
|
+
|
|
85
|
+
def create_endpoint(
|
|
86
|
+
self,
|
|
87
|
+
*,
|
|
88
|
+
url: str,
|
|
89
|
+
event_types: list[str] | None = None,
|
|
90
|
+
secret: str | None = None,
|
|
91
|
+
) -> Endpoint:
|
|
92
|
+
"""Register a new webhook endpoint."""
|
|
93
|
+
payload: dict[str, Any] = {"url": url}
|
|
94
|
+
if event_types:
|
|
95
|
+
payload["event_types"] = event_types
|
|
96
|
+
if secret:
|
|
97
|
+
payload["secret"] = secret
|
|
98
|
+
body = self._http.request("POST", "/v1/endpoints", json=payload)
|
|
99
|
+
return Endpoint.from_dict(body)
|
|
100
|
+
|
|
101
|
+
def update_endpoint(
|
|
102
|
+
self,
|
|
103
|
+
endpoint_id: str,
|
|
104
|
+
*,
|
|
105
|
+
url: str | None = None,
|
|
106
|
+
enabled: bool | None = None,
|
|
107
|
+
event_types: list[str] | None = None,
|
|
108
|
+
) -> Endpoint:
|
|
109
|
+
"""Update an existing endpoint."""
|
|
110
|
+
payload: dict[str, Any] = {}
|
|
111
|
+
if url is not None:
|
|
112
|
+
payload["url"] = url
|
|
113
|
+
if enabled is not None:
|
|
114
|
+
payload["enabled"] = enabled
|
|
115
|
+
if event_types is not None:
|
|
116
|
+
payload["event_types"] = event_types
|
|
117
|
+
body = self._http.request(
|
|
118
|
+
"PATCH", f"/v1/endpoints/{endpoint_id}", json=payload
|
|
119
|
+
)
|
|
120
|
+
return Endpoint.from_dict(body)
|
|
121
|
+
|
|
122
|
+
def disable_endpoint(self, endpoint_id: str) -> None:
|
|
123
|
+
"""Soft-delete (disable) an endpoint."""
|
|
124
|
+
self._http.request("DELETE", f"/v1/endpoints/{endpoint_id}")
|
|
125
|
+
|
|
126
|
+
# ============ Lifecycle ============
|
|
127
|
+
|
|
128
|
+
def close(self) -> None:
|
|
129
|
+
"""Close the underlying HTTP client."""
|
|
130
|
+
self._http.close()
|
|
131
|
+
|
|
132
|
+
def __enter__(self) -> "Relay":
|
|
133
|
+
return self
|
|
134
|
+
|
|
135
|
+
def __exit__(self, *args: Any) -> None:
|
|
136
|
+
self.close()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Exception hierarchy for the Relay SDK."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class RelayError(Exception):
|
|
5
|
+
"""Base exception for all Relay SDK errors."""
|
|
6
|
+
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
message: str,
|
|
10
|
+
*,
|
|
11
|
+
status: int | None = None,
|
|
12
|
+
code: str | None = None,
|
|
13
|
+
) -> None:
|
|
14
|
+
super().__init__(message)
|
|
15
|
+
self.message = message
|
|
16
|
+
self.status = status
|
|
17
|
+
self.code = code
|
|
18
|
+
|
|
19
|
+
def __repr__(self) -> str:
|
|
20
|
+
parts = [f"message={self.message!r}"]
|
|
21
|
+
if self.status is not None:
|
|
22
|
+
parts.append(f"status={self.status}")
|
|
23
|
+
if self.code:
|
|
24
|
+
parts.append(f"code={self.code!r}")
|
|
25
|
+
return f"{self.__class__.__name__}({', '.join(parts)})"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class AuthenticationError(RelayError):
|
|
29
|
+
"""401/403 — Invalid or missing API key."""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class NotFoundError(RelayError):
|
|
33
|
+
"""404 — Resource does not exist."""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class ValidationError(RelayError):
|
|
37
|
+
"""400/409 — Request body or parameters are invalid."""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class RateLimitError(RelayError):
|
|
41
|
+
"""429 — Rate limit exceeded."""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ServerError(RelayError):
|
|
45
|
+
"""5xx — Server-side error."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _raise_for_status(status: int, code: str | None, message: str) -> None:
|
|
49
|
+
"""Raise the appropriate exception based on HTTP status code."""
|
|
50
|
+
if 200 <= status < 300:
|
|
51
|
+
return
|
|
52
|
+
|
|
53
|
+
status_map: dict[int, type[RelayError]] = {
|
|
54
|
+
400: ValidationError,
|
|
55
|
+
401: AuthenticationError,
|
|
56
|
+
403: AuthenticationError,
|
|
57
|
+
404: NotFoundError,
|
|
58
|
+
409: ValidationError,
|
|
59
|
+
429: RateLimitError,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if status in status_map:
|
|
63
|
+
exc_cls = status_map[status]
|
|
64
|
+
elif status >= 500:
|
|
65
|
+
exc_cls = ServerError
|
|
66
|
+
else:
|
|
67
|
+
exc_cls = RelayError
|
|
68
|
+
|
|
69
|
+
raise exc_cls(message, status=status, code=code)
|
relay_python/models.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Data models for the Relay SDK."""
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _parse_dt(value: str | None) -> datetime | None:
|
|
8
|
+
if not value:
|
|
9
|
+
return None
|
|
10
|
+
return datetime.fromisoformat(value.replace("Z", "+00:00"))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class Event:
|
|
15
|
+
"""A webhook event submitted to Relay."""
|
|
16
|
+
|
|
17
|
+
id: str
|
|
18
|
+
source: str
|
|
19
|
+
event_type: str
|
|
20
|
+
data: dict[str, Any]
|
|
21
|
+
status: str
|
|
22
|
+
created_at: datetime
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def from_dict(cls, d: dict[str, Any]) -> "Event":
|
|
26
|
+
return cls(
|
|
27
|
+
id=d["id"],
|
|
28
|
+
source=d["source"],
|
|
29
|
+
event_type=d["event_type"],
|
|
30
|
+
data=d.get("data", {}),
|
|
31
|
+
status=d["status"],
|
|
32
|
+
created_at=_parse_dt(d["created_at"]) or datetime.now(),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass(frozen=True)
|
|
37
|
+
class Endpoint:
|
|
38
|
+
"""A downstream webhook destination."""
|
|
39
|
+
|
|
40
|
+
id: str
|
|
41
|
+
url: str
|
|
42
|
+
enabled: bool
|
|
43
|
+
event_types: list[str]
|
|
44
|
+
created_at: datetime
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def from_dict(cls, d: dict[str, Any]) -> "Endpoint":
|
|
48
|
+
return cls(
|
|
49
|
+
id=d["id"],
|
|
50
|
+
url=d["url"],
|
|
51
|
+
enabled=d.get("enabled", True),
|
|
52
|
+
event_types=d.get("event_types", []),
|
|
53
|
+
created_at=_parse_dt(d["created_at"]) or datetime.now(),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass(frozen=True)
|
|
58
|
+
class Delivery:
|
|
59
|
+
"""A delivery attempt of an event to an endpoint."""
|
|
60
|
+
|
|
61
|
+
id: str
|
|
62
|
+
event_id: str
|
|
63
|
+
endpoint_id: str
|
|
64
|
+
status: str
|
|
65
|
+
response_status: int | None
|
|
66
|
+
attempt_count: int
|
|
67
|
+
next_retry_at: datetime | None
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def from_dict(cls, d: dict[str, Any]) -> "Delivery":
|
|
71
|
+
return cls(
|
|
72
|
+
id=d["id"],
|
|
73
|
+
event_id=d["event_id"],
|
|
74
|
+
endpoint_id=d["endpoint_id"],
|
|
75
|
+
status=d["status"],
|
|
76
|
+
response_status=d.get("response_status"),
|
|
77
|
+
attempt_count=d.get("attempt_count", 0),
|
|
78
|
+
next_retry_at=_parse_dt(d.get("next_retry_at")),
|
|
79
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: relay-python-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for Relay webhook delivery infrastructure
|
|
5
|
+
Project-URL: Homepage, https://github.com/rajputomsingh/Relay
|
|
6
|
+
Author-email: relay-python-sdk <omchouhan227@gmail.com>
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: relay,webhook-delivery,webhooks
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Requires-Dist: httpx>=0.27.0
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
18
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
19
|
+
Requires-Dist: pytest-httpx>=0.33; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
22
|
+
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# relay-python-sdk
|
|
26
|
+
|
|
27
|
+
Official Python SDK for [Relay](https://github.com/rajputomsingh/Relay).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
relay_python/__init__.py,sha256=0ly0xjgGLvYCoR1LspLM8OMjgeY5s5CFdYB8UOApxDA,441
|
|
2
|
+
relay_python/_http.py,sha256=QjJlA90G9Uwr0OyTVqICYW3hQOYIVktdYMnfH9_UB2M,1422
|
|
3
|
+
relay_python/client.py,sha256=l4xexXLJ5k2akM1oKpIhvQhWPv3ugEuVDKUxKq5Fr50,4437
|
|
4
|
+
relay_python/exceptions.py,sha256=fXjSSVp7azT0hszAKkIPT6g3S8wRck0jvR5UAw2MwnI,1750
|
|
5
|
+
relay_python/models.py,sha256=JE-Y24CUTgzO8pRkLyrLUj2zuFBwRjo0G_5z0d6ZjCo,1980
|
|
6
|
+
relay_python_sdk-0.1.0.dist-info/METADATA,sha256=BLYaQdXTBlshjxRH8MmJbeKzsLRC1IxU_kYZaBF9-EE,981
|
|
7
|
+
relay_python_sdk-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
8
|
+
relay_python_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=hpmDtDm0RtcimwZUVlpdL4rUpvQPnzhdllTRGra7844,11563
|
|
9
|
+
relay_python_sdk-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|