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

[client] deprecate SCO promote_to_indicator in favor of promote_to_indicator_v2 (#6171) #680

Merged
merged 10 commits into from
Jun 27, 2024

Conversation

labo-flg
Copy link
Member

@labo-flg labo-flg commented Jun 14, 2024

At the graphql API level:

  • promote incorrectly returns the original observable and is now deprecated
  • promoteToIndicator returns the newly created indicator

Proposed changes

The method api.stix_cyber_observable.promoto_to_indicator that uses gql promote mutation is kept but is now mlarked as deprecated.
New method api.stix_cyber_observable.promoto_to_indicator_v2 is created to use the new gql mutation promoteToIndicator.

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

First implementation of a deprecation strategy at the level of client-python.

We use a mixin so that the StixCyberObservable class inherits the deprecated behavior, moved to a dedicated sub module in entities.strix_cyber_observable.StixCyberObservableDeprecatedMixin
The examples are updated to use the new API, while the old API is tested for non-regression in an integration test.

Deprecated code is meant to live for 3 major versions, and then removed from the code base.

@labo-flg labo-flg force-pushed the opencti/issue/6171-promote-no-breaking-api branch 2 times, most recently from ac067f5 to 31e76c4 Compare June 17, 2024 17:33
…teToIndicator

* promote incorrectly returns the original observable and is now deprecated
* promoteToIndicator returns the newly created indicator
@labo-flg labo-flg force-pushed the opencti/issue/6171-promote-no-breaking-api branch from 6266de4 to ea1e330 Compare June 18, 2024 14:21
@labo-flg labo-flg force-pushed the opencti/issue/6171-promote-no-breaking-api branch from 19fddfc to f39d8af Compare June 18, 2024 14:38
@labo-flg labo-flg added the multi-repository When a PR requires several repository changes label Jun 19, 2024
@labo-flg labo-flg force-pushed the opencti/issue/6171-promote-no-breaking-api branch from 11b81e1 to e3827ba Compare June 19, 2024 08:52
@labo-flg labo-flg changed the title [client] deprecate mutation stixCyberObservableEdit.promote for promoteToIndicator [client] deprecate SCO promote_to_indicator in favor of promote_to_indicator_v2 Jun 19, 2024
@@ -0,0 +1,256 @@
INDICATOR_PROPERTIES = """
Copy link
Member Author

Choose a reason for hiding this comment

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

For code clarity, we want to extract the entities properties (used in GQL queries) in dedicated files.
This will 1) make the business code lighter, and 2) allow to use them in several files.

As the new promote_to_indicator_v2 method returns an indicator, I'm already in 2) use-case.

Comment on lines +13 to +17
@deprecation.deprecated(
deprecated_in="6.2",
removed_in="6.5",
details="Use promote_to_indicator_v2 instead.",
)
Copy link
Member Author

Choose a reason for hiding this comment

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

This will print a warning message if the method is used, allowing our users to maintain their scripts more easily, hopefully.

@labo-flg labo-flg added the filigran team use to identify PR from the Filigran team label Jun 19, 2024
@labo-flg labo-flg marked this pull request as ready for review June 19, 2024 13:27
@labo-flg labo-flg changed the title [client] deprecate SCO promote_to_indicator in favor of promote_to_indicator_v2 [client] deprecate SCO promote_to_indicator in favor of promote_to_indicator_v2 (#6171) Jun 21, 2024
@aHenryJard aHenryJard self-assigned this Jun 25, 2024
@labo-flg labo-flg merged commit e165ac1 into master Jun 27, 2024
6 checks passed
@labo-flg labo-flg deleted the opencti/issue/6171-promote-no-breaking-api branch June 27, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team multi-repository When a PR requires several repository changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants