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

api: u.pro.services.list.v1 #3262

Merged
merged 4 commits into from
Sep 4, 2024
Merged

api: u.pro.services.list.v1 #3262

merged 4 commits into from
Sep 4, 2024

Conversation

dheyay
Copy link
Contributor

@dheyay dheyay commented Aug 12, 2024

Why is this needed?

Adds the following api endpoint:
u.pro.services.list.v1

Test Steps


  • (un)check this to re-run the checklist action

Copy link

github-actions bot commented Aug 12, 2024

PR Checklist

How to use this checklist

How to use this checklist

PR Author

For each section, check a box when it is true.
Uncheck a box if it becomes un-true.
Then check the box at the bottom of the PR description to re-run the action that creates this checklist.
The action that creates and updates this comment will retain your edits.
The action will fail if the checklist is not completed.

PR Reviewer

Check that the PR checklist action did not fail.
Double check that the author filled out the checklist accurately.
If you disagree with a checklist item, start a conversation.
For example, the author may say they don't think integration tests are necessary, but you may disagree.

Bug References

None.

Confirm

  • I've properly referenced all bugs that this PR fixes
How to properly reference fixed bugs
  • If this PR is related to a Jira item, include an SC-1234 reference in the PR title
  • If this PR is fixes a GitHub issue, include a Fixes: #1234 reference in the commit that fixes the issue
  • If this PR is fixes a Launchpad bug, include a LP: #12345678 reference in the commit that fixes the issue

Test Updates

Unit Tests

  • I have updated or added any unit tests accordingly
  • No unit test changes are necessary for this change

Integration Tests

  • I have updated or added any integration tests accordingly
  • No integration test changes are necessary for this change

Documentation

  • Changes here need to be documented and I have referenced the docs PR in the description
  • No documentation updates are necessary for this change

Does this PR require review from someone outside the core ubuntu-pro-client team?

  • Yes, and I have requested those reviews via GitHub
  • No

features/api_services_list.feature Outdated Show resolved Hide resolved
return ServiceListResult(services=services_list)


def _get_service_status(cfg, ent, inapplicable_resources):
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this problem was not introduced in this PR, but I think an entitlement should be able to tell its status. We have logic on different places that check if a service is enabled. I think we should consolidate then on the entitlement class. What do you think @orndorffgrant @renanrodrigo ?

Copy link
Member

Choose a reason for hiding this comment

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

agreed, but in a separate changeset imho

Copy link
Contributor

@lucasmoura lucasmoura left a comment

Choose a reason for hiding this comment

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

@dheyay Let's also add a description to the commit explaining what the API does

features/api_services_list.feature Outdated Show resolved Hide resolved
features/api_services_list.feature Outdated Show resolved Hide resolved
@dheyay
Copy link
Contributor Author

dheyay commented Aug 20, 2024

Updated @lucasmoura

features/api_services_list.feature Outdated Show resolved Hide resolved
features/api_services_list.feature Outdated Show resolved Hide resolved
features/api_services_list.feature Outdated Show resolved Hide resolved
features/api_services_list.feature Outdated Show resolved Hide resolved
features/api_services_list.feature Outdated Show resolved Hide resolved
uaclient/api/u/pro/services/list/v1.py Outdated Show resolved Hide resolved
uaclient/api/u/pro/services/list/v1.py Outdated Show resolved Hide resolved
@renanrodrigo
Copy link
Member

  • No unit test changes are necessary for this change

Well you are technically adding a unit. Why wouldn't we need the test?

@dheyay
Copy link
Contributor Author

dheyay commented Aug 22, 2024

Updated @renanrodrigo @lucasmoura

features/api_services_list.feature Outdated Show resolved Hide resolved
features/api_services_list.feature Outdated Show resolved Hide resolved
@dheyay dheyay force-pushed the status-api-serviceList branch 2 times, most recently from 606cd8b to 8978583 Compare August 22, 2024 20:11
uaclient/api/u/pro/services/list/v1.py Outdated Show resolved Hide resolved
uaclient/api/u/pro/services/list/v1.py Outdated Show resolved Hide resolved
uaclient/api/u/pro/services/list/v1.py Outdated Show resolved Hide resolved
entitled = False
elif contract_status == ContractStatus.ENTITLED:
entitled = True
available = True if ent.name not in inapplicable_resources else False
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should generally be using ent.applicability_status() for the value of available - right @lucasmoura @renanrodrigo ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @dheyay is just replicating the logic we have on status here. However, I think it is worth testing out replacing this logic with applicability_status

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 works with the applicability_status logic and does not need the additional inapplicable_resources. Updated the implementation and the endpoint/function names @orndorffgrant

@dheyay dheyay force-pushed the status-api-serviceList branch 3 times, most recently from 39ca3de to 73c5558 Compare August 29, 2024 21:23
Copy link
Member

@renanrodrigo renanrodrigo left a comment

Choose a reason for hiding this comment

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

So I still think we could have a couple unit tests for the basic functionality here. The API implementation file has 0% coverage
I'm fine if we merge this without the test for now though, as we have precedents - we already have API files at 0%.

@dheyay
Copy link
Contributor Author

dheyay commented Aug 30, 2024

Updated with a unit test @orndorffgrant @renanrodrigo

Copy link
Collaborator

@orndorffgrant orndorffgrant left a comment

Choose a reason for hiding this comment

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

One minor update needed - preemptively approving

features/api/api.feature Outdated Show resolved Hide resolved
Adds an api endpoint to return the list of services with their
availability, entitlement and description
uses the newly added jq filter and schema to test the api output
@orndorffgrant orndorffgrant merged commit 75129ed into next-v35 Sep 4, 2024
21 of 24 checks passed
@orndorffgrant orndorffgrant deleted the status-api-serviceList branch September 4, 2024 17:02
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