-
Notifications
You must be signed in to change notification settings - Fork 3
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: bulk enable/disable audits #302
base: main
Are you sure you want to change the base?
Changes from 8 commits
00435c9
6bbbffa
00fa62c
924650c
2a97058
6014416
5971d85
ff6e142
53b90ad
8685326
5f4e530
e0ca1b6
fb45552
57dc03a
c30427a
0c3e480
1db4063
c4ec341
0a28d20
747e4c9
6e3dd9e
7f234e5
cc5f505
859f899
3e01356
6e696ba
c694b40
24bbd14
5db3d4d
1d2d0e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,3 +125,47 @@ sites-for-organization: | |
$ref: './responses.yaml#/500' | ||
security: | ||
- api_key: [ ] | ||
bulk-update-sites-audit-config: | ||
patch: | ||
tags: | ||
- site | ||
summary: Enable/Disable audits for multiple sites | ||
description: | | ||
This endpoint is useful for enabling audit types for multiple sites. | ||
operationId: bulkUpdateAuditConfigForSites | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
baseURLs: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the primary key of sites is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is coming from #115, because if we want to easily use the API, we know the baseURL of a site, whereas for the id we need to do another request There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @solaris007 , the consumers generally know the site URL and it's a hassle for them to:
In all requests we've received about configuring/looking at some data for a site, only the URL is mentioned (or sometimes just the customer name), not the site id. |
||
type: array | ||
items: | ||
$ref: './schemas.yaml#/URL' | ||
auditTypes: | ||
type: array | ||
items: | ||
type: string | ||
examples: | ||
- 404 | ||
- broken-backlinks | ||
- organic-traffic | ||
enableAudits: | ||
type: boolean | ||
responses: | ||
'207': | ||
description: A list of sites | ||
content: | ||
application/json: | ||
schema: | ||
$ref: './schemas.yaml#/BulkUpdateSitesConfigResponse' | ||
'401': | ||
$ref: './responses.yaml#/401' | ||
'500': | ||
$ref: './responses.yaml#/500' | ||
security: | ||
- admin_key: [ ] | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import BaseCommand from './base.js'; | ||
import bulkUpdateSitesConfig from '../../../controllers/sites.js'; | ||
|
||
const PHRASES = ['bulk enable audits']; | ||
|
||
function BulkEnableAuditsCommand(context) { | ||
const baseCommand = BaseCommand({ | ||
id: 'bulk-enable-audits', | ||
name: 'Bulk Enable Audits', | ||
description: 'Enables audits for multiple sites.', | ||
phrases: PHRASES, | ||
usageText: `${PHRASES[0]} {site1,site2,...} {auditType1,auditType2,...}`, | ||
}); | ||
|
||
const { log } = context; | ||
|
||
const handleExecution = async (args, slackContext) => { | ||
const { say } = slackContext; | ||
|
||
try { | ||
const [baseURLsInput, auditTypesInput] = args; | ||
|
||
const baseURLs = baseURLsInput.split(','); | ||
const auditTypes = auditTypesInput.split(','); | ||
|
||
const enableAudits = true; | ||
|
||
const responses = await bulkUpdateSitesConfig({ | ||
data: { baseURLs, enableAudits, auditTypes }, | ||
}); | ||
|
||
let message = 'Bulk update completed with the following responses:\n'; | ||
responses.forEach((response) => { | ||
message += `- ${response.baseURL}: ${response.response.status}\n`; | ||
}); | ||
|
||
await say(message); | ||
} catch (error) { | ||
log.error(error); | ||
await say(`Error during bulk update: ${error.message}`); | ||
} | ||
}; | ||
|
||
baseCommand.init(context); | ||
|
||
return { | ||
...baseCommand, | ||
handleExecution, | ||
}; | ||
} | ||
|
||
export default BulkEnableAuditsCommand; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description and operationId don't seem to match to what the code does, which is also affect organization config...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because as of now, we cannot enable a site without enabling the org. Please confirm @iuliag or @ekremney
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's fine - all i'm saying is the API doc should transparently describe the effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to rename to make this more clear.
Specifically for enabling the org, I will add here the discussion I had with @alinarublea :
Users might not always want to enable/disable at the org level when they do this for the site.
E.g. case we had with a customer, where we had to enable the whole org and disable a part of the sites within that org. So we need a way to disable at site level without disabling at the same time at org level.
For enable = true, it's pointless to enable just the site, because anyways the audit doesn't run unless the org is enabled as well. In this case, we'd want to unify those 2 changes in 1 API call.