-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Allow API Namespace to auto clean resources (#1493)
Addresses: #1383 https://user-images.githubusercontent.com/50227291/227561742-94afc461-9731-49e5-a759-06492b8b84fd.mov Co-authored-by: Pralish Kayastha <[email protected]>
- Loading branch information
1 parent
fd1986b
commit 489e7ab
Showing
18 changed files
with
583 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class PurgeOldApiResourcesJob | ||
include Sidekiq::Job | ||
|
||
def perform(api_namespace_id) | ||
api_namespace = ApiNamespace.find_by(id: api_namespace_id) | ||
api_namespace&.destroy_old_api_resources_in_batches | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
%div | ||
%p | ||
%b Requires authentication: | ||
= api_namespace.requires_authentication | ||
%p | ||
%b Namespace type: | ||
= api_namespace.namespace_type | ||
|
||
.card.bg-white | ||
.card-body | ||
= render partial: 'rest_interface', locals: { api_namespace: api_namespace } | ||
|
||
.card-body | ||
%h4 | ||
Graph Interface | ||
%strong | ||
Request description endpoint: | ||
%p | ||
GET | ||
%pre | ||
= "#{graphql_base_url(Subdomain.current, api_namespace)}/describe" | ||
|
||
%strong | ||
Request query endpoint: | ||
%p | ||
POST | ||
%pre | ||
= "#{graphql_base_url(Subdomain.current, api_namespace)}" | ||
%p | ||
Payload (this) | ||
%pre | ||
= "query: { apiNamespaces(slug: \"#{api_namespace.slug}\") { id } }" | ||
%p | ||
Payload (this + children) | ||
%pre | ||
= "query: { apiNamespaces(slug: \"#{api_namespace.slug}\") { id apiResources { id } } }" | ||
%p | ||
Payload (global) | ||
%pre | ||
= "query: { apiNamespaces { id } }" | ||
|
||
.card-body | ||
%h4 | ||
Webhook | ||
.table-responsive | ||
%table | ||
%thead | ||
%tr | ||
%th.px-3 API Connection | ||
%th.px-3 HTTP method | ||
%th.px-3 Webhook Interface | ||
%th.px-3 Verification Method | ||
%tbody | ||
- api_namespace.external_api_clients.where(drive_strategy: ExternalApiClient::DRIVE_STRATEGIES[:webhook]).each do |external_api_client| | ||
%tr | ||
%td.px-3= link_to external_api_client.label, api_namespace_external_api_client_path(api_namespace_id: external_api_client.api_namespace.id, id: external_api_client.id) | ||
%td.px-3 POST | ||
%td.px-3= api_external_api_client_webhook_url(version: external_api_client.api_namespace.version, api_namespace: external_api_client.api_namespace.slug, external_api_client: external_api_client.slug) | ||
%td.px-3= external_api_client.webhook_verification_method&.webhook_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- has_full_read_access = has_access_to_api_accessibility?(ApiNamespace::API_ACCESSIBILITIES[:full_read_access], current_user, api_namespace) | ||
- has_allow_settings_access = has_access_to_api_accessibility?(ApiNamespace::API_ACCESSIBILITIES[:allow_settings], current_user, api_namespace) | ||
- if has_allow_settings_access || has_full_read_access | ||
.card.p-3.mb-4 | ||
= form_with(method: :patch, model: api_namespace, url: settings_api_namespace_path(api_namespace)) do |f| | ||
.form-group | ||
= f.label :purge_resources_older_than | ||
= f.select :purge_resources_older_than, options_for_select(ApiNamespace::RESOURCES_PURGE_INTERVAL_MAPPING, api_namespace.purge_resources_older_than), { }, {class: 'form-control', disabled: !has_allow_settings_access} | ||
|
||
- if has_allow_settings_access | ||
.form-group.mb-0 | ||
= f.submit "Submit", class: 'btn btn-primary', data: { confirm: 'This will trigger a purge job that will delete all API resources older than the selected interval.' } | ||
|
||
.my-3 | ||
= link_to 'Delete', api_namespace, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' | ||
.my-3 | ||
= link_to 'Duplicate with associations', duplicate_with_associations_api_namespace_path(id: api_namespace.id), method: :post, target: '_blank', class: 'btn btn-primary' | ||
.my-3 | ||
= link_to 'Duplicate without associations', duplicate_without_associations_api_namespace_path(id: api_namespace.id), method: :post, target: '_blank', class: 'btn btn-primary' |
8 changes: 1 addition & 7 deletions
8
app/views/comfy/admin/api_namespaces/api_resources/_index.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.