Skip to content
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

storeapi: move from details (v1) to info (v2) #2550

Merged
merged 7 commits into from
May 3, 2019

Conversation

sergiusens
Copy link
Collaborator

Instead of accessing each element from the returned calls as dictionary
elements, this implementation offers classes with attributes and some
methods to interact with the API results.

Signed-off-by: Sergio Schvezov sergio.schvezov@canonical.com

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run ./runtests.sh static?
  • Have you successfully run ./runtests.sh tests/unit?

This implementation strays away from the existing implementation pattern of what lives in the storeapi package but I personally think, even if more work initially, will provide easier ways to interact with the results when the Snap Store API is not fresh in your head.

Instead of accessing each element from the returned calls as dictionary
elements, this implementation offers classes with attributes and some
methods to interact with the API results.

Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
Copy link
Contributor

@cprov cprov left a comment

Choose a reason for hiding this comment

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

Thanks, @sergiusens

params = dict()
params[
"fields"
] = "channel-map, snap,snap-id,name,publisher,confinement,revision"
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a stray space before snap, but this field doesn't not exist and it's not needed anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed, valid fields are not documented though, are they? they also seem to be flattened, correct?

:return Details for the snap.
:rtype: dict
:return information for the snap.
:rtype: SnapInfo
"""
headers = self.get_default_headers()
headers.update(
{
"Accept": "application/hal+json",
Copy link
Contributor

Choose a reason for hiding this comment

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

v2 responses are technically only application/json, we can drop the hal+ part

Copy link
Contributor

@cmatsuoka cmatsuoka left a comment

Choose a reason for hiding this comment

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

It seems good on the Python side but I don't know details about the store API changes, so I'll leave the final approval for @cprov.

snapcraft/internal/build_providers/_snap.py Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented May 2, 2019

Codecov Report

Merging #2550 into master will decrease coverage by 0.16%.
The diff coverage is 80.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2550      +/-   ##
==========================================
- Coverage   89.02%   88.86%   -0.17%     
==========================================
  Files         201      202       +1     
  Lines       13611    13772     +161     
  Branches     2067     2079      +12     
==========================================
+ Hits        12117    12238     +121     
- Misses       1056     1090      +34     
- Partials      438      444       +6
Impacted Files Coverage Δ
snapcraft/storeapi/_client.py 100% <100%> (ø) ⬆️
snapcraft/storeapi/errors.py 85.24% <100%> (+0.24%) ⬆️
snapcraft/plugins/kernel.py 94.24% <100%> (ø) ⬆️
snapcraft/_store.py 94.26% <100%> (ø) ⬆️
snapcraft/file_utils.py 96.31% <100%> (+0.02%) ⬆️
snapcraft/internal/build_providers/_snap.py 90.09% <61.11%> (-4.65%) ⬇️
snapcraft/storeapi/info.py 81.88% <81.88%> (ø)
snapcraft/storeapi/_snap_index_client.py 76.08% <83.33%> (-1.7%) ⬇️
snapcraft/storeapi/_store_client.py 81.86% <86.66%> (-1.31%) ⬇️
snapcraft/internal/pluginhandler/_plugin_loader.py 82.65% <0%> (-2.05%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddb2d26...ae4260d. Read the comment docs.

Copy link
Contributor

@cmatsuoka cmatsuoka left a comment

Choose a reason for hiding this comment

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

All points raised by @cprov addressed, approving!

@sergiusens sergiusens merged commit 40a1886 into canonical:master May 3, 2019
@sergiusens sergiusens deleted the details-to-info branch May 3, 2019 01:54
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.

4 participants