Skip to content

Commit 9b51525

Browse files
committed
Docs, CI, etc.
Signed-off-by: Denis Makogon <lildee1991@gmail.com>
1 parent 132fe61 commit 9b51525

File tree

3 files changed

+103
-2
lines changed

3 files changed

+103
-2
lines changed

.github/pull_request_template.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- Link to issue this resolves
2+
3+
- What I did
4+
5+
- How I did it
6+
7+
- How to verify it
8+
9+
- One line description for the changelog

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
1-
# sdk-python
2-
Python SDK for CloudEvents
1+
# Python SDK for [CloudEvents](https://github.com/cloudevents/spec)
2+
3+
**NOTE: This SDK is still considered work in progress, things might (and will) break with every update.**
4+
5+
Package **cloudevents** provides primitives to work with CloudEvents specification: https://github.com/cloudevents/spec.
6+
7+
Parsing upstream Event from HTTP Request:
8+
```python
9+
from cloudevents.sdk.event import upstream
10+
from cloudevents.sdk import marshaller
11+
12+
data = "<this is where your CloudEvent comes from>"
13+
m = marshaller.NewDefaultHTTPMarshaller(upstream.Event)
14+
event = m.FromRequest({"Content-Type": "application/cloudevents+json"}, data)
15+
16+
```
17+
18+
Creating a minimal CloudEvent in version 0.1:
19+
```python
20+
from cloudevents.sdk.event import v01
21+
22+
event = (
23+
v01.Event().
24+
WithContentType("application/json").
25+
WithData('{"name":"john"}').
26+
WithEventID("my-id").
27+
WithSource("from-galaxy-far-far-away").
28+
WithEventTime("tomorrow").
29+
WithEventType("cloudevent.greet.you")
30+
)
31+
32+
```
33+
34+
Creating HTTP request from CloudEvent:
35+
```python
36+
from cloudevents.sdk import converters
37+
from cloudevents.sdk import marshaller
38+
from cloudevents.sdk.converters import structured
39+
from cloudevents.sdk.event import v01
40+
41+
event = (
42+
v01.Event().
43+
WithContentType("application/json").
44+
WithData('{"name":"john"}').
45+
WithEventID("my-id").
46+
WithSource("from-galaxy-far-far-away").
47+
WithEventTime("tomorrow").
48+
WithEventType("cloudevent.greet.you")
49+
)
50+
m = marshaller.NewHTTPMarshaller(
51+
[
52+
structured.NewJSONHTTPCloudEventConverter(type(event))
53+
]
54+
)
55+
56+
headers, body = m.ToRequest(event, converters.TypeStructured, lambda x: x)
57+
58+
```
59+
60+
The goal of this package is to provide support for all released versions of CloudEvents, ideally while maintaining
61+
the same API. It will use semantic versioning with following rules:
62+
* MAJOR version increments when backwards incompatible changes is introduced.
63+
* MINOR version increments when backwards compatible feature is introduced INCLUDING support for new CloudEvents version.
64+
* PATCH version increments when a backwards compatible bug fix is introduced.

circle.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/python:3.7.0
6+
working_directory: ~/sdk-python
7+
steps:
8+
- checkout
9+
- restore_cache:
10+
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
11+
- setup_remote_docker:
12+
docker_layer_caching: true
13+
- run:
14+
command: |
15+
python3 -m venv venv
16+
. venv/bin/activate
17+
pip install tox
18+
pip install -r requirements.txt
19+
- save_cache:
20+
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
21+
paths:
22+
- "venv"
23+
- run:
24+
command: |
25+
. venv/bin/activate
26+
tox -epep8
27+
- run:
28+
command: |
29+
. venv/bin/activate
30+
tox -epy3.7

0 commit comments

Comments
 (0)