Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update types and handle data_base64 structured. #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 8, 2020

Conversation

evankanderson
Copy link
Contributor

I added tests

  • One line description for the changelog
Update python types and handle structured `data_base64`.

Note that this is probably a breaking API change because the expected types for data_marshaller and data_unmarshaller changed and all previous clients needed to supply these.

- Add sane defaults for encoding
  - Unfortunately, defaults for structured and binary need to be *different*
   - Push types through interfaces
- Make it easy to call 'ToRequest' using Marshaller defaults
- Add tests for above

Signed-off-by: Evan Anderson <[email protected]>
@evankanderson
Copy link
Contributor Author

I figured out how to fix the lint warnings; since it appears that the current configuration checks both W503 and W504, which are contradictory.

@evankanderson
Copy link
Contributor Author

@denismakogon any interest in this?

@evankanderson
Copy link
Contributor Author

Ping?

@evankanderson
Copy link
Contributor Author

evankanderson commented Jun 5, 2020 via email

@grant
Copy link
Member

grant commented Jun 8, 2020

@evankanderson Who are you pinging?

@evankanderson
Copy link
Contributor Author

I think @denismakogon is the only one who can approve/merge, but maybe @duglin can assist?

@duglin
Copy link
Contributor

duglin commented Jun 9, 2020

I can merge but I'd need at least one person who knows python to review... I don't know python

@duglin
Copy link
Contributor

duglin commented Jun 9, 2020

@di ^^^

@di di self-requested a review June 9, 2020 15:58
Copy link
Member

@di di left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple small things.

@di di changed the base branch from master to v1.0.0-dev June 11, 2020 16:31
@grant
Copy link
Member

grant commented Jun 22, 2020

Ping @evankanderson. It looks like you have a couple pending requested changes here.

@evankanderson
Copy link
Contributor Author

@di Thanks for the previous review; ready for another look.

@evankanderson evankanderson force-pushed the simplify-args branch 2 times, most recently from 600e688 to ddfc749 Compare June 25, 2020 21:48
di
di previously approved these changes Jun 25, 2020
Copy link
Member

@di di left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once DCO is passing (let me know if you need help with that)

@cumason123
Copy link
Contributor

Needs to update samples/http-cloudevents sample code

Copy link
Contributor

@cumason123 cumason123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part everything looks good. I do have a couple design questions/nits however.

To my understanding, a consumer must first strip cloudevent fields of the ce- prefix before instantiating a CloudEvent. Could we perhaps do this field stripping internally to reduce overhead for consumers?

from flask import Flask, request
from cloudevents.sdk.http_events import CloudEvent
app = Flask(__name__)

@app.route("/", methods=["POST"])
def echo():
    attributes = {}
    
    contenttype = request.headers.get('Content-Type')
    if contenttype is not None:
        attributes['Content-Type'] = contenttype
        
    # unsure if passing None quietly fails thus I verify if field exists before
    # passing it into the CloudEvent   
    ce_type = request.headers.get('ce-type', request.form.get('type'))
    if ce_type is not None:
        # CloudEvent atm explicitly wants non ce- prefixed cloudevent fields
        attributes['type'] = ce_type
        
    ce_id = request.headers.get('ce-id', request.form.get('id'))
    if ce_id is not None:
        attributes['id'] = ce_id
        
    ce_source = request.headers.get('ce-source', request.form.get('source'))
    if ce_source is not None:
        attributes['source'] = ce_source
       
    ce_specversion = request.headers.get('ce-specversion', request.form.get('specversion'))
    if ce_specversion is not None:
        attributes['specversion'] = ce_specversion
    
    data = request.form.get('data_base64', request.form.get('data'))
    event = CloudEvent(attributes, data)
    
    # Do some work
    return '', 204

if __name__ == '__main__':
    app.run()
    

However this is how a consumer would ideally like to instantiate events:

from flask import Flask, request
from cloudevents.sdk.http_events import CloudEvent
app = Flask(__name__)

@app.route("/", methods=["POST"])
def home():
    headers = dict(request.form)
    body = dict(request.headers)
    
    # CloudEvent automatically parses the http headers/body
    event = CloudEvent(headers, body)
    
    # Do some work 
    return '', 204

if __name__ == '__main__':
    app.run()
    

Copy link

@MarcBoissonneault MarcBoissonneault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love these additions/changes, keep up the good work!

Comment on lines 38 to 58
def FromHttp(
cls,
data: typing.Union[str, bytes],
headers: dict = {},
data_unmarshaller: types.UnmarshallerType = None
):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we decide to not follow the pep8 convention for naming of python methods:
pep8 says they should be:

    def from_http(...) -> ...:
        ...

Also can we make sure to do "complete type hints":

Suggested change
def FromHttp(
cls,
data: typing.Union[str, bytes],
headers: dict = {},
data_unmarshaller: types.UnmarshallerType = None
):
def from_http(
cls,
data: typing.IO,
headers: typing.Dict[str, typing.Any],
data_unmarshaller: types.UnmarshallerType = None
) -> CloudEvent:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, this is a class method, but point taken on naming, and I totally forgot to document the return type.

It's also incorrect to omit the HTTP headers, so removing the default is correct.

I'm not sure about the argument type hints:

  • typing.IO expects to have a read() method, but a quick survey of 3 popular Python libraries (flask, requests, sanic), suggests that the normal exposure of the request body is via a string where the library handles the read, rather than exposing the underlying socket.

  • I think the headers dict from HTTP clients would be a typing.Dict[str, str], not a [str, typing.Any], no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm -- it turns out that I can't use -> CloudEvent to document the return type, because the class is not defined until after all the functions have been defined (including this one).

Thoughts?

Copy link

@MarcBoissonneault MarcBoissonneault Jul 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm -- it turns out that I can't use -> CloudEvent to document the return type, because the class is not defined until after all the functions have been defined (including this one).

Thoughts?

for this add the following at the top:

from __future__ import annotations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this:

typing.IO expects to have a read() method, but a quick survey of 3 popular Python libraries (flask, requests, sanic), suggests that the normal exposure of the request body is via a string where the library handles the read, rather than exposing the underlying socket.

I just used the exact same typehints that the current implementation is using here: https://github.com/cloudevents/sdk-python/blob/master/cloudevents/sdk/marshaller.py#L45

BUT after reading your comment, I think you are right!
And for the headers I also think you are right!

So, double 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that PEP 563 is only supported in Python 3.7 or later.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and that's exactly why the added this feature in the "future" module.

And this line in the imports:

from __future__ import annotations

And it should work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work on Python 3.6, which is in the test suite.

I tried adding a PR to do that, and the 3.6 tests (only) failed. If we can abandon 3.6, I'd be happy to make the change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python 3.6 won't be EOL until Dec 2021, so I think we should probably continue to support it.

@@ -17,6 +17,7 @@ commands =
flake8

[flake8]
ignore = H405,H404,H403,H401,H306,S101,N802,N803,N806,I202,I201
# See https://gitlab.com/pycqa/flake8/-/issues/466 for extend-ignore vs ignore
extend-ignore = H405,H404,H403,H401,H306,S101,N802,N803,N806,I202,I201

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All those "ignore" seems to indicate that we are not following standard python conventions ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://flake8.pycqa.org/en/latest/user/error-codes.html

Not sure what these are; I discovered that extend-ignore was having issues with W503/W504, where flake8 changed the behavior.

  • H405, H404, H403, H401 are all about docstrings and spaces (I noticed some of these)
  • S101 - Multi-line missing trailing comma
  • N802, N803, N806 - function names lowercase, argument name lowercase, functiov in variable lowercase.
  • I201, I202 - Newlines between import groups

Maybe we can clean these up in a separate PR before 1.0.0?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FOR SURE we can change that in another PR!!!
It was just a comment about this whole repo where there seems to have lot of ignored rules...
Usually when we ignore rules it's because we don't like them or because we don't know the standard of the language.

Another thoughts here, personally I prefer pylint as linter (compare to flake8) since you can ignore rule by name instead of by "rule code" that are so hard (impossible) to remember.
For example, see this stackoverflow comment from 2014: https://stackoverflow.com/questions/4341746/how-do-i-disable-a-pylint-warning/23542817#23542817

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree on the code not feeling pythonic -- the existing code feels very Java-ish to me.

With that said, coming from go-land, I hate linters because it introduces human debug-fix loops where presumably the machine could do the formatting for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree (these linting settings also predate me). I'd prefer if we just used https://pypi.org/project/black/, which includes an auto-formatter.

@cumason123
Copy link
Contributor

Can we adjust the sample code at samples/http-cloudevents, or should we do that in a separate PR?

@evankanderson
Copy link
Contributor Author

evankanderson commented Jul 2, 2020

For the most part everything looks good. I do have a couple design questions/nits however.

To my understanding, a consumer must first strip cloudevent fields of the ce- prefix before instantiating a CloudEvent. Could we perhaps do this field stripping internally to reduce overhead for consumers?

I think your understanding is colored by looking at the API through the lens of HTTP-Binary, with an assumed JSON payload. 😁 Ideally, the CloudEvents class would be both transport and payload independent, so you could send an "image/jpeg" event as a POST reply, or store a CloudEvent as an AVRO structured format in Kafka.

To instantiate a CloudEvent, the customer should provide the attribute names, rather than the HTTP-Binary header names. If you want to convert an HTTP-Binary request to a CloudEvent use CloudEvent.FromHttp(body, headers), which should take an un-decoded body and possibly a data_marshaller if the payload is something exotic, rather than JSON.

However this is how a consumer would ideally like to instantiate events:

from flask import Flask, request
from cloudevents.sdk.http_events import CloudEvent
app = Flask(__name__)

@app.route("/", methods=["POST"])
def home():
    headers = dict(request.form)
    body = dict(request.headers)
    
    # CloudEvent automatically parses the http headers/body
    event = CloudEvent(headers, body)
    
    # Do some work 
    return '', 204

if __name__ == '__main__':
    app.run()
    

I'd suggest the following for reading CloudEvents, which will work whether or not the CloudEvents payload is JSON:

from flask import Flask, request
from cloudevents.sdk.http_events import CloudEvent
app = Flask(__name__)

@app.route("/", methods=["POST"])
def home():
    # CloudEvent automatically parses the http headers/body, whether or not the body is JSON
    event = CloudEvent.FromHttp(request.get_data(), request.headers)

    # Do some work 
    return '', 204

if __name__ == '__main__':
    app.run()
    

@evankanderson
Copy link
Contributor Author

Needs to update samples/http-cloudevents sample code

Any thoughts on whether/how we could add a test that the sample works?

Copy link
Contributor Author

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, PTAL!

@@ -17,6 +17,7 @@ commands =
flake8

[flake8]
ignore = H405,H404,H403,H401,H306,S101,N802,N803,N806,I202,I201
# See https://gitlab.com/pycqa/flake8/-/issues/466 for extend-ignore vs ignore
extend-ignore = H405,H404,H403,H401,H306,S101,N802,N803,N806,I202,I201
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://flake8.pycqa.org/en/latest/user/error-codes.html

Not sure what these are; I discovered that extend-ignore was having issues with W503/W504, where flake8 changed the behavior.

  • H405, H404, H403, H401 are all about docstrings and spaces (I noticed some of these)
  • S101 - Multi-line missing trailing comma
  • N802, N803, N806 - function names lowercase, argument name lowercase, functiov in variable lowercase.
  • I201, I202 - Newlines between import groups

Maybe we can clean these up in a separate PR before 1.0.0?

Comment on lines 38 to 58
def FromHttp(
cls,
data: typing.Union[str, bytes],
headers: dict = {},
data_unmarshaller: types.UnmarshallerType = None
):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm -- it turns out that I can't use -> CloudEvent to document the return type, because the class is not defined until after all the functions have been defined (including this one).

Thoughts?

@evankanderson evankanderson force-pushed the simplify-args branch 2 times, most recently from c079493 to 4a45198 Compare July 2, 2020 22:12
@evankanderson evankanderson force-pushed the simplify-args branch 2 times, most recently from 748b896 to e4f2d2f Compare July 3, 2020 04:47
Fix usability of binary detection in MarshalJSON to support memoryview.

Signed-off-by: Evan Anderson <[email protected]>
@evankanderson
Copy link
Contributor Author

Hope everyone had a good 4th of July weekend!

I've updated the README.md; please take a look at the new API(s), since I've made breaking changes. I suspect that's okay given the pre-1.0 library and generally low adoption. If there are further changes we should make, it's probably better to make them sooner than later.

I've added a test for uploading bz2-encoded binary data and round-tripping that through the library. I didn't do a raw test for that because the content is opaque, but I can add one if it feels important.

data_unmarshaller = _json_or_string

event = marshaller.NewDefaultHTTPMarshaller().FromRequest(
v1.Event(), headers, data, data_unmarshaller)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we toggle between v1.Event() and v03.Event() depending on specversion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until we've parsed the event, it's hard to find the specversion. Fortunately, since we extract everything from the Event and throw it away, all we need are the parsing, which seems to be the same path for v3 and v1.

I agree that it's not ideal, but I think it will take a bunch of refactoring to separate the attribute extraction from the representation.

Copy link
Contributor

@cumason123 cumason123 Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. I'll make an issue for this once the PR gets merged to keep the diff count low.

@grant
Copy link
Member

grant commented Jul 7, 2020

Are we good to merge this @evankanderson @cumason123?

@grant grant requested a review from cumason123 July 7, 2020 15:49
@di di dismissed their stale review July 7, 2020 15:53

Out of date

@cumason123 cumason123 self-requested a review July 7, 2020 16:00
Copy link
Contributor

@cumason123 cumason123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible refactor we can do either here or in a future PR:

...
from cloudevents.sdk import converters

headers, body = event.to_http(converters.TypeBinary)

could be refactored into:

headers, body = event.to_http(isbinary=True)

User no longer has to import converters. Functionally speaking, converters only has two possible string types anyways.

@evankanderson
Copy link
Contributor Author

I'd prefer to keep the types for now.

My suspicion is that to_http and from_http are actually not the correct methods on a CloudEvent, because then we'll need to add to_kafka, to_amqp, etc.

I agree that it would be nice to have a better way to type event.to_http(converters.TypeBinary), but I think I might prefer to spell it http.binary.emit(event) or http.structured.parse(headers, body).

@evankanderson
Copy link
Contributor Author

It looks like there are approvals and no requested changes. @cumason123 -- are you comfortable with this being committed?

@cumason123 cumason123 merged commit 7e054fa into cloudevents:v1.0.0-dev Jul 8, 2020
cumason123 pushed a commit to cumason123/sdk-python that referenced this pull request Jul 22, 2020
* Update types and handle data_base64 structured.

- Add sane defaults for encoding
  - Unfortunately, defaults for structured and binary need to be *different*
   - Push types through interfaces
- Make it easy to call 'ToRequest' using Marshaller defaults
- Add tests for above

Signed-off-by: Evan Anderson <[email protected]>

* Fix lint warnings due to changes to W503/W504

See https://gitlab.com/pycqa/flake8/-/issues/466 for details.

Signed-off-by: Evan Anderson <[email protected]>

* Adopt di's suggestions.

Signed-off-by: Evan Anderson <[email protected]>

* Fix lint.

Signed-off-by: Evan Anderson <[email protected]>

* Move types to another package.

Signed-off-by: Evan Anderson <[email protected]>

* Adjust CloudEvent class in http_events.py to support binary data as well as JSON.

Signed-off-by: Evan Anderson <[email protected]>

* Apply suggested changes by MacrBoissonneault

Signed-off-by: Evan Anderson <[email protected]>

* Fix samples as well.

Signed-off-by: Evan Anderson <[email protected]>

* Fix lint. Apparently, we can complain about formating issues, but a human has to fix them.

Signed-off-by: Evan Anderson <[email protected]>

* Add test for binary encoding of messages.

Fix usability of binary detection in MarshalJSON to support memoryview.

Signed-off-by: Evan Anderson <[email protected]>

* Fix errors noticed by cumason123

Signed-off-by: Evan Anderson <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>
cumason123 added a commit that referenced this pull request Aug 11, 2020
* Created CloudEvent class (#36)

CloudEvents is a more pythonic interface for using cloud events.
It is powered by internal marshallers and cloud event base classes.
It performs basic validation on fields, and cloud event type checking.

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* Implemented python properties in base.py (#41)

* Added SetCloudEventVersion

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* began adding python properties

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* added pythonic properties to base class

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* began testing for getters/setters

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* added general setter tests

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* fixed spacing in base.py

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* added __eq__ to option and datacontentencoding property to v03

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* lint fixes

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* testing extensions and old getters

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* removed versions v01 and v02 from test_data_encaps_refs.py

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* fixed inheritance issue in CloudEvent

Signed-off-by: Curtis Mason <[email protected]>

* added prefixed_headers dict to test

Signed-off-by: Curtis Mason <[email protected]>

* Http structured cloudevents (#47)

* Moved fields out of base & structured support

base._ce_required_fields and base._ce_optional_fields were moved into
event classes v03 and v1.

http_events.CloudEvent class now looks for fieldnames in either headers
or data, and can automatically determine whether this is a binary or
structured event.

Signed-off-by: Curtis Mason <[email protected]>

* testing structured

Signed-off-by: Curtis Mason <[email protected]>

* added tests for structured events

Signed-off-by: Curtis Mason <[email protected]>

* Added test valid structured cloudevents

Signed-off-by: Curtis Mason <[email protected]>

* Created default headers arg in CloudEvent

Signed-off-by: Curtis Mason <[email protected]>

* Added http_events.py sample code

Signed-off-by: Curtis Mason <[email protected]>

* removed ../python-event-requests

Signed-off-by: Curtis Mason <[email protected]>

* README.md nit

Signed-off-by: Curtis Mason <[email protected]>

* client.py nit

Signed-off-by: Curtis Mason <[email protected]>

* comment nits

Signed-off-by: Curtis Mason <[email protected]>

* created __getitem__ in CloudEvent

Signed-off-by: Curtis Mason <[email protected]>

* sample nits

Signed-off-by: Curtis Mason <[email protected]>

* fixed structured empty data issue

Signed-off-by: Curtis Mason <[email protected]>

* Added CloudEvent to README

Signed-off-by: Curtis Mason <[email protected]>

* added http_msg to CloudEvent

Signed-off-by: Curtis Mason <[email protected]>

* implemented ToRequest in CloudEvent

Signed-off-by: Curtis Mason <[email protected]>

* testing more specversions

Signed-off-by: Curtis Mason <[email protected]>

* Added sample code to README.md

Signed-off-by: Curtis Mason <[email protected]>

* modified sample code

Signed-off-by: Curtis Mason <[email protected]>

* added datavalidation to changelog

Signed-off-by: Curtis Mason <[email protected]>

* updated README

Signed-off-by: Curtis Mason <[email protected]>

* README adjustment

Signed-off-by: Curtis Mason <[email protected]>

* ruler 80 adjustment on http_events

Signed-off-by: Curtis Mason <[email protected]>

* style and renamed ToRequest to to_request

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* fixed self.binary typo

Signed-off-by: Curtis Mason <[email protected]>

* CHANGELOG adjustment

Signed-off-by: Curtis Mason <[email protected]>

* rollback CHANGELOG

Signed-off-by: Curtis Mason <[email protected]>

* Added documentation to to_request

Signed-off-by: Curtis Mason <[email protected]>

* README.md adjustment

Signed-off-by: Curtis Mason <[email protected]>

* renamed event_handler to event_version

Signed-off-by: Curtis Mason <[email protected]>

* inlined field_name_modifier

Signed-off-by: Curtis Mason <[email protected]>

* renamed test body data

Signed-off-by: Curtis Mason <[email protected]>

* removed unnecessary headers from test

Signed-off-by: Curtis Mason <[email protected]>

* removed field_name_modifier and fixed e.g. in client.py

Signed-off-by: Curtis Mason <[email protected]>

* pylint fix

Signed-off-by: Curtis Mason <[email protected]>

* Update types and handle data_base64 structured. (#34)

* Update types and handle data_base64 structured.

- Add sane defaults for encoding
  - Unfortunately, defaults for structured and binary need to be *different*
   - Push types through interfaces
- Make it easy to call 'ToRequest' using Marshaller defaults
- Add tests for above

Signed-off-by: Evan Anderson <[email protected]>

* Fix lint warnings due to changes to W503/W504

See https://gitlab.com/pycqa/flake8/-/issues/466 for details.

Signed-off-by: Evan Anderson <[email protected]>

* Adopt di's suggestions.

Signed-off-by: Evan Anderson <[email protected]>

* Fix lint.

Signed-off-by: Evan Anderson <[email protected]>

* Move types to another package.

Signed-off-by: Evan Anderson <[email protected]>

* Adjust CloudEvent class in http_events.py to support binary data as well as JSON.

Signed-off-by: Evan Anderson <[email protected]>

* Apply suggested changes by MacrBoissonneault

Signed-off-by: Evan Anderson <[email protected]>

* Fix samples as well.

Signed-off-by: Evan Anderson <[email protected]>

* Fix lint. Apparently, we can complain about formating issues, but a human has to fix them.

Signed-off-by: Evan Anderson <[email protected]>

* Add test for binary encoding of messages.

Fix usability of binary detection in MarshalJSON to support memoryview.

Signed-off-by: Evan Anderson <[email protected]>

* Fix errors noticed by cumason123

Signed-off-by: Evan Anderson <[email protected]>

* Changelog version deprecation (#48)

* added changelog

Signed-off-by: Curtis Mason <[email protected]>

* Created CloudEvent class (#36)

CloudEvents is a more pythonic interface for using cloud events.
It is powered by internal marshallers and cloud event base classes.
It performs basic validation on fields, and cloud event type checking.

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Fix tox configuration for CI (#46)

Signed-off-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Implemented python properties in base.py (#41)

* Added SetCloudEventVersion

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* began adding python properties

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* added pythonic properties to base class

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* began testing for getters/setters

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* added general setter tests

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* fixed spacing in base.py

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* added __eq__ to option and datacontentencoding property to v03

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* lint fixes

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* testing extensions and old getters

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* removed versions v01 and v02 from test_data_encaps_refs.py

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Dustin Ingram <[email protected]>

* fixed inheritance issue in CloudEvent

Signed-off-by: Curtis Mason <[email protected]>

* added prefixed_headers dict to test

Signed-off-by: Curtis Mason <[email protected]>

* CHANGELOG adjustment

Signed-off-by: Curtis Mason <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Removed irrelevant files from commit diff

Signed-off-by: Curtis Mason <[email protected]>

Co-authored-by: Dustin Ingram <[email protected]>

* Black formatter (#51)

* black and isort added to precommit

Signed-off-by: Curtis Mason <[email protected]>

* main renaming

Signed-off-by: Curtis Mason <[email protected]>

* fixed tox

Signed-off-by: Curtis Mason <[email protected]>

* linting in tox rename

Signed-off-by: Curtis Mason <[email protected]>

* fixed tox trailing space

Signed-off-by: Curtis Mason <[email protected]>

* added reformat tox env

Signed-off-by: Curtis Mason <[email protected]>

* Reformatting files

Signed-off-by: Curtis Mason <[email protected]>

* reformatted more files

Signed-off-by: Curtis Mason <[email protected]>

* documented tox in README

Signed-off-by: Curtis Mason <[email protected]>

* removed -rc flag

Signed-off-by: Curtis Mason <[email protected]>

* README and http-cloudevents sample code adjustments to reflect new CloudEvent (#56)

* README and http-cloudevents CloudEvent adjustments

README no longer shows how to use base event classes to create events.
Removed this because users shouldn't be forced to interact with the
marshaller class. Additionally, CloudEvent is a simpler interface
therefore we are encouraging the CloudEvent class usage.
http-cloudevents now has more example usage for the getitem overload.
Similarly README shows how to use getitem overload.

Signed-off-by: Curtis Mason <[email protected]>

* lint reformat

Signed-off-by: Curtis Mason <[email protected]>

* resolved nits

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* renamed /mycontext to url

Signed-off-by: Curtis Mason <[email protected]>

* renamed here linlk to in the samples directory

Signed-off-by: Curtis Mason <[email protected]>

* Separated http methods (#60)

* instantiated http path

Signed-off-by: Curtis Mason <[email protected]>

* moved from_http from CloudEvent to http

Signed-off-by: Curtis Mason <[email protected]>

* Moved to_http out of CloudEvent

Signed-off-by: Curtis Mason <[email protected]>

* moved http library into event.py

Signed-off-by: Curtis Mason <[email protected]>

* testing printable cloudevent

Signed-off-by: Curtis Mason <[email protected]>

* Adjusted README

Signed-off-by: Curtis Mason <[email protected]>

* Created EventClass

Signed-off-by: Curtis Mason <[email protected]>

* reformatted event.py

Signed-off-by: Curtis Mason <[email protected]>

* from_json definition

Signed-off-by: Curtis Mason <[email protected]>

* server print changes

Signed-off-by: Curtis Mason <[email protected]>

* Specversion toggling (#57)

* cloudevent now switches specversion types

Signed-off-by: Curtis Mason <[email protected]>

* removed duplicate marshall instance

Signed-off-by: Curtis Mason <[email protected]>

* resolved grant requests

Signed-off-by: Curtis Mason <[email protected]>

* converters now can check headers for fields

Signed-off-by: Curtis Mason <[email protected]>

* removed print statement

Signed-off-by: Curtis Mason <[email protected]>

* Fixed marshallers looking at headers for specversion

Signed-off-by: Curtis Mason <[email protected]>

* lint fixes

Signed-off-by: Curtis Mason <[email protected]>

* is_binary static method and structured isinstance rework

Signed-off-by: Curtis Mason <[email protected]>

* testing for is_binary and is_structured

Signed-off-by: Curtis Mason <[email protected]>

* Image sample code (#65)

* added image example

Signed-off-by: Curtis Mason <[email protected]>

* moved size into headers

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* renamed sample code

Signed-off-by: Curtis Mason <[email protected]>

* added test to http-image-cloudevents sample

Signed-off-by: Curtis Mason <[email protected]>

* removed unnecessary function

Signed-off-by: Curtis Mason <[email protected]>

* Added testing for http-image-cloudevents

Signed-off-by: Curtis Mason <[email protected]>

* Data marshall arg fix and better image in sample

Fixed bug where data_marshaller and data_unmarshaller wasn't being
passed into positional arguments. Also used cloudevents logo for the
image in http-image-cloudevents

Signed-off-by: Curtis Mason <[email protected]>

* adjusted http-image-cloudevents samples

Signed-off-by: Curtis Mason <[email protected]>

* reformat and README changes

Signed-off-by: Curtis Mason <[email protected]>

* io bytes casting in data_unmarshaller

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* removed unusued imports in http-image samples

Signed-off-by: Curtis Mason <[email protected]>

* removed samples/http-cloudevents/tmp.png

Signed-off-by: Curtis Mason <[email protected]>

* Nits

Signed-off-by: Curtis Mason <[email protected]>

* Implemented to_json and from_json (#72)

* added test_to_json test

Signed-off-by: Curtis Mason <[email protected]>

* implemented to_json with tests

Signed-off-by: Curtis Mason <[email protected]>

* from_json and to_json tests

Signed-off-by: Curtis Mason <[email protected]>

* Tests for to_json being able to talk to from_json

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* added documentation for to_json and from_json

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* Fixed top level extensions bug (#71)

* Fixed top level extensions bug

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* fixed name bug in test_event_extensions

Signed-off-by: Curtis Mason <[email protected]>

* fixed broken links in README.md (#75)

Signed-off-by: Curtis Mason <[email protected]>

* Fixed marshaller documentation typo's in http (#76)

* Fixed marshaller documentation in http directory

Signed-off-by: Curtis Mason <[email protected]>

* adjusted marshaller documentation

Signed-off-by: Curtis Mason <[email protected]>

* None data fix (#78)

* fixed none data issue

Signed-off-by: Curtis Mason <[email protected]>

* added none data test for marshalling

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* Samples image test server (#79)

* fixed none data issue

Signed-off-by: Curtis Mason <[email protected]>

* added none data test for marshalling

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* added http server test in image sample

Signed-off-by: Curtis Mason <[email protected]>

* Removed print statements from test

Signed-off-by: Curtis Mason <[email protected]>

* removed requests from test

Signed-off-by: Curtis Mason <[email protected]>

* Top level http (#83)

* Modularized http and made http a top level module

Modularized the http directory by separating related functions into
different scripts. Also removed EventClass and kept a singular
CloudEvent. Finally, CloudEvent.__repr__ was refactored such that it
doesn't depend on external methods.

Signed-off-by: Curtis Mason <[email protected]>

* renamed requests.py to http_methods

Signed-off-by: Curtis Mason <[email protected]>

* lint fixes

Signed-off-by: Curtis Mason <[email protected]>

* http-json-cloudevents testing (#80)

* Added tests to http-json-cloudevents

Signed-off-by: Curtis Mason <[email protected]>

* removed outdated python-requests sample code

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* Added flask to requirements

Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

* docs: add README badge (#85)

Signed-off-by: Grant Timmerman <[email protected]>

* added pypi-release rule (#87)

* added pypi-release rule

Signed-off-by: Curtis Mason <[email protected]>

* added RELEASING.md

Signed-off-by: Curtis Mason <[email protected]>

* Adjusted RELEASING.md

Signed-off-by: Curtis Mason <[email protected]>

* Update .github/workflows/pypi-release.yml

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* workflow pypi name changed

Signed-off-by: Curtis Mason <[email protected]>

* Update RELEASING.md

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Update RELEASING.md

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Update RELEASING.md

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* removed some pbr stuff

Signed-off-by: Curtis Mason <[email protected]>

* Removed all pbr stuff

Signed-off-by: Curtis Mason <[email protected]>

* README nits

Signed-off-by: Curtis Mason <[email protected]>

* RELEASING adjustment in README

Signed-off-by: Curtis Mason <[email protected]>

* author update in setup.cfg

Signed-off-by: Curtis Mason <[email protected]>

* removed setup.cfg

Signed-off-by: Curtis Mason <[email protected]>

* Update setup.py

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* lint fix

Signed-off-by: Curtis Mason <[email protected]>

Co-authored-by: Dustin Ingram <[email protected]>

* pypi-release git tags automation (#88)

* added pypi_packaging

Signed-off-by: Curtis Mason <[email protected]>

* reverted pypi-release

Signed-off-by: Curtis Mason <[email protected]>

* added pypi_package workflow

Signed-off-by: Curtis Mason <[email protected]>

* added gitpython dependency

Signed-off-by: Curtis Mason <[email protected]>

* added git import in createTag function

Signed-off-by: Curtis Mason <[email protected]>

* Updated RELEASING.md and implemented pypi_config in pypi_packaging.pg

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Fixed some docs

Signed-off-by: Curtis Mason <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* Update .github/workflows/pypi-release.yml

Co-authored-by: Dustin Ingram <[email protected]>
Signed-off-by: Curtis Mason <[email protected]>

* added __version__

Signed-off-by: Curtis Mason <[email protected]>

* lint change

Signed-off-by: Curtis Mason <[email protected]>

* reinstalling cloudevents in workflow

Signed-off-by: Curtis Mason <[email protected]>

* added cloudevents to publish.txt

Signed-off-by: Curtis Mason <[email protected]>

* removed old release_doc

Signed-off-by: Curtis Mason <[email protected]>

Co-authored-by: Dustin Ingram <[email protected]>

Co-authored-by: Evan Anderson <[email protected]>
Co-authored-by: Dustin Ingram <[email protected]>
Co-authored-by: Grant Timmerman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SDK must serialize/deserialize binary data to/from data_base64 instead of data
6 participants