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: CRUD jobs configurations #831

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

martinst06
Copy link

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description. Or if there's no issue created, make sure you
    describe here the problem you're solving.
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

If the PR is changing the API specification:

  • make sure you add a "Not implemented yet" note the endpoint description, if the implementation is not ready
    yet. Ideally, return a 501 status code with a message explaining the feature is not implemented yet.
  • make sure you add at least one example of the request and response.

If the PR is changing the API implementation or an entity exposed through the API:

  • make sure you update the API specification and the examples to reflect the changes.

If the PR is introducing a new audit type:

  • make sure you update the API specification with the type, schema of the audit result and an example

Related Issues

Thanks for contributing!

@martinst06 martinst06 requested a review from solaris007 March 27, 2025 09:38
@martinst06 martinst06 self-assigned this Mar 27, 2025
Copy link

This PR will trigger a minor release when merged.

@martinst06 martinst06 requested review from solaris007 and alinarublea and removed request for solaris007 March 28, 2025 11:36
@varu-adobe
Copy link

dummy comment

Copy link
Contributor

@iuliag iuliag left a comment

Choose a reason for hiding this comment

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

The PR goes in a good direction. There are still some adjustments required as mentioned in the comments.
It would generally help reviewers to have a more visual way to check the rendered API docs alongside reviewing fragments of yamls, so we generally add in the PR description/comments screenshots of important sections changed.

schema:
type: array
items:
$ref: './schemas.yaml#/Configuration'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be just the job configuration? not the whole configuration including handlers, queues etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

While checking the Configuration schema, I realized handlers and slackRoles properties are not documented in our API docs. This could be a follow-up update to the docs.

content:
application/json:
schema:
$ref: './schemas.yaml#/Configuration'
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, response should be just the jobs sections of the configuration, including the version alongside, since that may be helpful.

content:
application/json:
schema:
$ref: './schemas.yaml#/Configuration'
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

- configuration
summary: Delete the latest jobs configurations by type
description: |
This endpoint is useful for deleting the latest jobs configurations by a specific type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading this, I'm unclear what delete means. Does it mean we create a new configuration version that doesn't contain that job type anymore? Could explain in the description?

$ref: './responses.yaml#/401'
'500':
$ref: './responses.yaml#/500'
post:
Copy link
Contributor

Choose a reason for hiding this comment

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

The post needs a requestBody schema.

JobType:
type: string
enum:
- 'import'
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a current job type, we should enumerate and give as example below existing job types such as: broken-backlinks, all-traffic, forms-opportunities etc.
Also, do we consider job type to be unique in the jobs list?


const currentJobs = latestConfig.getJobs();
const updatedConfig = await Configuration.update({
jobs: [...currentJobs, ...jobsData],
Copy link
Contributor

Choose a reason for hiding this comment

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

This allows for duplicates to be pushed into the array, no? @solaris007, should we require job.type to be unique in the list and handle this in the validation/updated list accordingly?

const updateData = context.body;

if (!isObject(updateData)) {
return badRequest('Update data must be an object');
Copy link
Contributor

Choose a reason for hiding this comment

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

You should also validate the updateData or the final object obtained by the merge contains valid values for the required properties.

version: latestConfig.getVersion(),
});

return ok(ConfigurationDto.toJSON(updatedConfig));
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above, if the response status code is 207, then the response should contain a status for each update. If partial success/failure is not a case here, then status response should rather be 200.

$ref: './responses.yaml#/404'
'500':
$ref: './responses.yaml#/500'
patch:
Copy link
Contributor

Choose a reason for hiding this comment

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

The patch needs a requestBody schema.

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