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

feat(incidents): implement models and client for /incidents/secrets/ #115

Conversation

fnareoh
Copy link
Contributor

@fnareoh fnareoh commented Aug 23, 2024

Implement this endpoint to later display more information in ggshield.

After discussion with Aurélien, we chose to use Litteral when string values are known to be part of limited number of options. We chose not to use Enum in order not to be too restrictive and risk breaking change when a new return value is added in the API.

@fnareoh fnareoh self-assigned this Aug 23, 2024
@fnareoh fnareoh requested a review from agateau-gg August 23, 2024 15:04
@fnareoh fnareoh force-pushed the garancegourdel/scrt-4759-optimize-files-to-scan-on-merge-commits branch from ccd992f to 4b05ac9 Compare August 23, 2024 15:07
@fnareoh fnareoh requested review from salome-voltz and removed request for agateau-gg August 23, 2024 15:08
Copy link
Collaborator

@agateau-gg agateau-gg left a comment

Choose a reason for hiding this comment

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

Minor remarks, but thanks for this not-so-fun work.

if callable(schema_klass):
schema = schema_klass()
else:
schema = schema_klass
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is some kind of undocumented standard to declare our models and their schema. It looks like this:

@dataclass
class Foo(Base, FromDictMixin):
    # fields


FooSchema = cast(
    Type[BaseSchema], marshmallow_dataclass.class_schema(Foo, BaseSchema)
)

Foo.SCHEMA = FooSchema()

If you do this for the schemas you are testing here, you won't need these changes and the code will be a little more consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum I was not entirely sure I understood your suggestion but I think successfully applied it ? 😅

retrieve_secret_incident handles the /incidents/secret/{incident_id} endpoint of the API

:param incident_id: incident id
:param with_occurrences: number of occurrences of the incident to retrieve (default 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you clarify whether 0 means no occurrences are retrieved or if it means the server uses its own default value?

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 had put 0 when I didn't think we wanted occurrences but I meant to change this default to 20 (which is the default of the API), done now.

@fnareoh fnareoh force-pushed the garancegourdel/scrt-4759-optimize-files-to-scan-on-merge-commits branch from 4b05ac9 to 91cd3f8 Compare August 26, 2024 15:30
@fnareoh fnareoh force-pushed the garancegourdel/scrt-4759-optimize-files-to-scan-on-merge-commits branch from 91cd3f8 to dce0ec3 Compare August 26, 2024 15:57
@fnareoh fnareoh requested review from agateau-gg and removed request for salome-voltz August 27, 2024 08:19
@agateau-gg agateau-gg merged commit 215f529 into master Aug 28, 2024
19 checks passed
@agateau-gg agateau-gg deleted the garancegourdel/scrt-4759-optimize-files-to-scan-on-merge-commits branch August 28, 2024 07:22
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.

3 participants