Skip to content

Commit cda44dd

Browse files
authored
Update docs (#31)
* Update README to show v1 examples Signed-off-by: Dustin Ingram <[email protected]> * Update release process Signed-off-by: Dustin Ingram <[email protected]> * Update CHANGELOG Signed-off-by: Dustin Ingram <[email protected]>
1 parent bcacf33 commit cda44dd

File tree

5 files changed

+118
-65
lines changed

5 files changed

+118
-65
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [0.3.0]
88
### Added
99
- Added Cloudevents V0.3 and V1 implementations ([#22])
1010
- Add helpful text to README ([#23])
@@ -45,7 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4545
### Added
4646
- Initial release
4747

48-
[Unreleased]: https://github.com/cloudevents/sdk-python/compare/0.2.4...HEAD
48+
[0.3.0]: https://github.com/cloudevents/sdk-python/compare/0.2.4...HEAD
4949
[0.2.4]: https://github.com/cloudevents/sdk-python/compare/0.2.3...0.2.4
5050
[0.2.3]: https://github.com/cloudevents/sdk-python/compare/0.2.2...0.2.3
5151
[0.2.2]: https://github.com/cloudevents/sdk-python/compare/0.2.1...0.2.2

README.md

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,77 +6,106 @@ This SDK is still considered a work in progress, therefore things might (and
66
will) break with every update.
77

88
This SDK current supports the following versions of CloudEvents:
9+
- v1.0
10+
- v0.3
911
- v0.2
1012
- v0.1
1113

1214
## Python SDK
1315

1416
Package **cloudevents** provides primitives to work with CloudEvents specification: https://github.com/cloudevents/spec.
1517

16-
Parsing upstream Event from HTTP Request:
18+
Parsing upstream structured Event from HTTP request:
19+
1720
```python
1821
import io
1922

20-
from cloudevents.sdk.event import v02
23+
from cloudevents.sdk.event import v1
2124
from cloudevents.sdk import marshaller
2225

2326
m = marshaller.NewDefaultHTTPMarshaller()
27+
2428
event = m.FromRequest(
25-
v02.Event(),
29+
v1.Event(),
30+
{"content-type": "application/cloudevents+json"},
31+
io.StringIO(
32+
"""
33+
{
34+
"specversion": "1.0",
35+
"datacontenttype": "application/json",
36+
"type": "word.found.name",
37+
"id": "96fb5f0b-001e-0108-6dfe-da6e2806f124",
38+
"time": "2018-10-23T12:28:22.4579346Z",
39+
"source": "<source-url>"
40+
}
41+
"""
42+
),
43+
lambda x: x.read(),
44+
)
45+
```
46+
47+
Parsing upstream binary Event from HTTP request:
48+
49+
```python
50+
import io
51+
52+
from cloudevents.sdk.event import v1
53+
from cloudevents.sdk import marshaller
54+
55+
m = marshaller.NewDefaultHTTPMarshaller()
56+
57+
event = m.FromRequest(
58+
v1.Event(),
2659
{
27-
"content-type": "application/cloudevents+json",
28-
"ce-specversion": "0.2",
29-
"ce-time": "2018-10-23T12:28:22.4579346Z",
60+
"ce-specversion": "1.0",
61+
"content-type": "application/json",
62+
"ce-type": "word.found.name",
3063
"ce-id": "96fb5f0b-001e-0108-6dfe-da6e2806f124",
64+
"ce-time": "2018-10-23T12:28:22.4579346Z",
3165
"ce-source": "<source-url>",
32-
"ce-type": "word.found.name",
3366
},
34-
io.BytesIO(b"this is where your CloudEvent data"),
35-
lambda x: x.read()
67+
io.BytesIO(b"this is where your CloudEvent data"),
68+
lambda x: x.read(),
3669
)
37-
3870
```
3971

4072
Creating a minimal CloudEvent in version 0.1:
73+
4174
```python
42-
from cloudevents.sdk.event import v01
75+
from cloudevents.sdk.event import v1
4376

4477
event = (
45-
v01.Event().
46-
SetContentType("application/json").
47-
SetData('{"name":"john"}').
48-
SetEventID("my-id").
49-
SetSource("from-galaxy-far-far-away").
50-
SetEventTime("tomorrow").
51-
SetEventType("cloudevent.greet.you")
78+
v1.Event()
79+
.SetContentType("application/json")
80+
.SetData('{"name":"john"}')
81+
.SetEventID("my-id")
82+
.SetSource("from-galaxy-far-far-away")
83+
.SetEventTime("tomorrow")
84+
.SetEventType("cloudevent.greet.you")
5285
)
53-
5486
```
5587

5688
Creating HTTP request from CloudEvent:
89+
5790
```python
5891
from cloudevents.sdk import converters
5992
from cloudevents.sdk import marshaller
6093
from cloudevents.sdk.converters import structured
61-
from cloudevents.sdk.event import v01
94+
from cloudevents.sdk.event import v1
6295

6396
event = (
64-
v01.Event().
65-
SetContentType("application/json").
66-
SetData('{"name":"john"}').
67-
SetEventID("my-id").
68-
SetSource("from-galaxy-far-far-away").
69-
SetEventTime("tomorrow").
70-
SetEventType("cloudevent.greet.you")
71-
)
72-
m = marshaller.NewHTTPMarshaller(
73-
[
74-
structured.NewJSONHTTPCloudEventConverter()
75-
]
97+
v1.Event()
98+
.SetContentType("application/json")
99+
.SetData('{"name":"john"}')
100+
.SetEventID("my-id")
101+
.SetSource("from-galaxy-far-far-away")
102+
.SetEventTime("tomorrow")
103+
.SetEventType("cloudevent.greet.you")
76104
)
77105

78-
headers, body = m.ToRequest(event, converters.TypeStructured, lambda x: x)
106+
m = marshaller.NewHTTPMarshaller([structured.NewJSONHTTPCloudEventConverter()])
79107

108+
headers, body = m.ToRequest(event, converters.TypeStructured, lambda x: x)
80109
```
81110

82111
## HOWTOs with various Python HTTP frameworks
@@ -85,7 +114,7 @@ In this topic you'd find various example how to integrate an SDK with various HT
85114

86115
### Python requests
87116

88-
One of popular framework is [0.2-force-improvements](http://docs.python-requests.org/en/master/).
117+
One of popular framework is [`requests`](http://docs.python-requests.org/en/master/).
89118

90119

91120
#### CloudEvent to request

release.sh

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
11
#!/usr/bin/env bash
22

3+
# Fail fast and fail hard.
4+
set -eo pipefail
35

6+
# Check for our version
7+
if [ -z "$CLOUDEVENTS_SDK_VERSION" ]; then
8+
echo "Need to set CLOUDEVENTS_SDK_VERSION"
9+
exit 1
10+
fi
11+
12+
# Run tests on target branch
13+
tox
14+
15+
# Cut off stable branch
416
git checkout -b v${CLOUDEVENTS_SDK_VERSION}-stable
17+
18+
# Create GitHub tag
19+
git tag -a ${CLOUDEVENTS_SDK_VERSION} -m "${CLOUDEVENTS_SDK_VERSION}"
20+
21+
# Build distribution package
22+
rm -rf dist
23+
pip install -U setuptools wheel
24+
python setup.py sdist bdist_wheel
25+
26+
# Submit relase to PyPI
27+
pip install -U twine
28+
twine upload dist/*
29+
30+
# Push the release to GitHub
531
git push origin v${CLOUDEVENTS_SDK_VERSION}-stable
6-
PBR_VERSION=${CLOUDEVENTS_SDK_VERSION} python setup.py sdist bdist_wheel
7-
twine upload dist/cloudevents-${CLOUDEVENTS_SDK_VERSIONN}*
32+
git push --tags
33+
34+
# Switch back to the master branch
835
git checkout master

release_doc.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,60 @@
1-
Release process
2-
===============
1+
# Release process
32

4-
Run tests on target brunch
5-
--------------------------
3+
## Run tests on target branch
64

75
Steps:
86

97
tox
108

11-
Cut off stable branch
12-
---------------------
9+
## Cut off stable branch
1310

1411
Steps:
1512

1613
git checkout -b vX.X.X-stable
17-
git push origin vX.X.X-stable
1814

1915

20-
Create GitHub tag
21-
-----------------
16+
## Create GitHub tag
2217

2318
Steps:
2419

25-
Releases ---> Draft New Release
26-
Name: CloudEvents Python SDK version X.X.X stable release
20+
git tag -a X.X.X -m "X.X.X"
2721

2822

29-
Collect changes from previous version
30-
-------------------------------------
23+
## Build distribution package
3124

3225
Steps:
3326

34-
git log --oneline --decorate
27+
rm -rf dist
28+
pip install -U setuptools wheel
29+
python setup.py sdist bdist_wheel
3530

3631

37-
Build distribution package
38-
--------------------------
32+
## Check install capability for the wheel
3933

4034
Steps:
4135

42-
PBR_VERSION=X.X.X python setup.py sdist bdist_wheel
36+
python3.7 -m venv .test_venv
37+
source .test_venv/bin/activate
38+
pip install dist/cloudevents-X.X.X-py3-none-any.whl
4339

4440

45-
Check install capability for the wheel
46-
--------------------------------------
41+
## Submit release to PyPI
4742

4843
Steps:
4944

50-
python3.7 -m venv .test_venv
51-
source .test_venv/bin/activate
52-
pip install dist/cloudevents-X.X.X-py3-none-any.whl
45+
pip install -U twine
46+
twine upload dist/*
5347

5448

55-
Submit release to PYPI
56-
----------------------
49+
## Push the release to GitHub
5750

5851
Steps:
5952

60-
twine upload dist/cloudevents-X.X.X-py3-none-any.whl
53+
git push origin vX.X.X-stable
54+
git push --tags
55+
6156

62-
Verify install capability for the wheel
63-
---------------------------------------
57+
## Verify install capability for the wheel
6458

6559
Steps:
6660

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ packages =
2424
[global]
2525
setup-hooks =
2626
pbr.hooks.setup_hook
27+
28+
[pbr]
29+
skip_changelog = True

0 commit comments

Comments
 (0)