web: fix more special API Calls

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-16 18:38:19 +02:00
parent ba5374f6e1
commit d38fd603dd
19 changed files with 25 additions and 268 deletions

View File

@ -107,7 +107,6 @@ router.register("core/users", UserViewSet)
router.register("core/user_consent", UserConsentViewSet) router.register("core/user_consent", UserConsentViewSet)
router.register("core/tokens", TokenViewSet) router.register("core/tokens", TokenViewSet)
router.register("outposts/outposts", OutpostViewSet)
router.register("outposts/instances", OutpostViewSet) router.register("outposts/instances", OutpostViewSet)
router.register("outposts/service_connections/all", ServiceConnectionViewSet) router.register("outposts/service_connections/all", ServiceConnectionViewSet)
router.register("outposts/service_connections/docker", DockerServiceConnectionViewSet) router.register("outposts/service_connections/docker", DockerServiceConnectionViewSet)

View File

@ -4061,248 +4061,6 @@ paths:
schema: schema:
$ref: '#/components/schemas/LDAPOutpostConfig' $ref: '#/components/schemas/LDAPOutpostConfig'
description: '' description: ''
/api/v2beta/outposts/outposts/:
get:
operationId: outposts_outposts_list
description: Outpost Viewset
parameters:
- name: ordering
required: false
in: query
description: Which field to use when ordering the results.
schema:
type: string
- name: page
required: false
in: query
description: A page number within the paginated result set.
schema:
type: integer
- name: page_size
required: false
in: query
description: Number of results to return per page.
schema:
type: integer
- in: query
name: providers__isnull
schema:
type: boolean
- name: search
required: false
in: query
description: A search term.
schema:
type: string
tags:
- outposts
security:
- authentik: []
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedOutpostList'
description: ''
post:
operationId: outposts_outposts_create
description: Outpost Viewset
tags:
- outposts
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OutpostRequest'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/OutpostRequest'
multipart/form-data:
schema:
$ref: '#/components/schemas/OutpostRequest'
required: true
security:
- authentik: []
- cookieAuth: []
responses:
'201':
content:
application/json:
schema:
$ref: '#/components/schemas/Outpost'
description: ''
/api/v2beta/outposts/outposts/{uuid}/:
get:
operationId: outposts_outposts_retrieve
description: Outpost Viewset
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
description: A UUID string identifying this outpost.
required: true
tags:
- outposts
security:
- authentik: []
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Outpost'
description: ''
put:
operationId: outposts_outposts_update
description: Outpost Viewset
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
description: A UUID string identifying this outpost.
required: true
tags:
- outposts
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OutpostRequest'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/OutpostRequest'
multipart/form-data:
schema:
$ref: '#/components/schemas/OutpostRequest'
required: true
security:
- authentik: []
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Outpost'
description: ''
patch:
operationId: outposts_outposts_partial_update
description: Outpost Viewset
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
description: A UUID string identifying this outpost.
required: true
tags:
- outposts
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PatchedOutpostRequest'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/PatchedOutpostRequest'
multipart/form-data:
schema:
$ref: '#/components/schemas/PatchedOutpostRequest'
security:
- authentik: []
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Outpost'
description: ''
delete:
operationId: outposts_outposts_destroy
description: Outpost Viewset
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
description: A UUID string identifying this outpost.
required: true
tags:
- outposts
security:
- authentik: []
- cookieAuth: []
responses:
'204':
description: No response body
/api/v2beta/outposts/outposts/{uuid}/health/:
get:
operationId: outposts_outposts_health_list
description: Get outposts current health
parameters:
- name: ordering
required: false
in: query
description: Which field to use when ordering the results.
schema:
type: string
- in: query
name: providers__isnull
schema:
type: boolean
- name: search
required: false
in: query
description: A search term.
schema:
type: string
- in: path
name: uuid
schema:
type: string
format: uuid
description: A UUID string identifying this outpost.
required: true
tags:
- outposts
security:
- authentik: []
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/OutpostHealth'
description: ''
/api/v2beta/outposts/outposts/default_settings/:
get:
operationId: outposts_outposts_default_settings_retrieve
description: Global default outpost config
tags:
- outposts
security:
- authentik: []
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/OutpostDefaultConfig'
description: ''
/api/v2beta/outposts/proxy/: /api/v2beta/outposts/proxy/:
get: get:
operationId: outposts_proxy_list operationId: outposts_proxy_list

View File

@ -37,7 +37,7 @@ export class OutpostStatusChart extends AKChart<OutpostStats> {
let outdated = 0; let outdated = 0;
let unhealthy = 0; let unhealthy = 0;
await Promise.all(outposts.results.map(async (element) => { await Promise.all(outposts.results.map(async (element) => {
const health = await api.outpostsOutpostsHealthList({ const health = await api.outpostsInstancesHealthList({
uuid: element.pk || "", uuid: element.pk || "",
}); });
if (health.length === 0) { if (health.length === 0) {

View File

@ -55,7 +55,7 @@ export class TransportListPage extends TablePage<NotificationTransport> {
html` html`
<ak-action-button <ak-action-button
.apiRequest=${() => { .apiRequest=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsTest({ return new EventsApi(DEFAULT_CONFIG).eventsTransportsTestCreate({
uuid: item.pk || "", uuid: item.pk || "",
}); });
}}> }}>

View File

@ -18,7 +18,7 @@ export class FlowDiagram extends LitElement {
@property() @property()
set flowSlug(value: string) { set flowSlug(value: string) {
this._flowSlug = value; this._flowSlug = value;
new FlowsApi(DEFAULT_CONFIG).flowsInstancesDiagram({ new FlowsApi(DEFAULT_CONFIG).flowsInstancesDiagramRetrieve({
slug: value, slug: value,
}).then((data) => { }).then((data) => {
this.diagram = FlowChart.parse(data.diagram || ""); this.diagram = FlowChart.parse(data.diagram || "");

View File

@ -19,7 +19,7 @@ export class FlowImportForm extends Form<Flow> {
if (!file) { if (!file) {
throw new Error("No form data"); throw new Error("No form data");
} }
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesImportFlow({ return new FlowsApi(DEFAULT_CONFIG).flowsInstancesImportFlowCreate({
file: file file: file
}); });
}; };

View File

@ -89,7 +89,7 @@ export class FlowListPage extends TablePage<Flow> {
<button <button
class="pf-c-button pf-m-secondary" class="pf-c-button pf-m-secondary"
@click=${() => { @click=${() => {
new FlowsApi(DEFAULT_CONFIG).flowsInstancesExecute({ new FlowsApi(DEFAULT_CONFIG).flowsInstancesExecuteRetrieve({
slug: item.slug slug: item.slug
}).then(link => { }).then(link => {
window.location.assign(`${link.link}?next=/%23${window.location.href}`); window.location.assign(`${link.link}?next=/%23${window.location.href}`);

View File

@ -71,7 +71,7 @@ export class FlowViewPage extends LitElement {
<button <button
class="pf-c-button pf-m-secondary" class="pf-c-button pf-m-secondary"
@click=${() => { @click=${() => {
new FlowsApi(DEFAULT_CONFIG).flowsInstancesExecute({ new FlowsApi(DEFAULT_CONFIG).flowsInstancesExecuteRetrieve({
slug: this.flow.slug slug: this.flow.slug
}).then(link => { }).then(link => {
const finalURL = `${link.link}?next=/%23${window.location.href}`; const finalURL = `${link.link}?next=/%23${window.location.href}`;

View File

@ -38,7 +38,7 @@ export class GroupForm extends ModelForm<Group, string> {
groupRequest: data groupRequest: data
}); });
} else { } else {
data.users = Array.from(this.instance?.users || []) as unknown as Set<number>; data.users = Array.from(this.instance?.users || []);
return new CoreApi(DEFAULT_CONFIG).coreGroupsCreate({ return new CoreApi(DEFAULT_CONFIG).coreGroupsCreate({
groupRequest: data groupRequest: data
}); });
@ -83,7 +83,7 @@ export class GroupForm extends ModelForm<Group, string> {
// Because the model only has the IDs, map the user list to IDs // Because the model only has the IDs, map the user list to IDs
const ids = items.map(u => u.pk || 0); const ids = items.map(u => u.pk || 0);
if (!this.instance) this.instance = {} as Group; if (!this.instance) this.instance = {} as Group;
this.instance.users = new Set(Array.from(this.instance?.users || []).concat(ids)); this.instance.users = Array.from(this.instance?.users || []).concat(ids);
this.requestUpdate(); this.requestUpdate();
return Promise.resolve(); return Promise.resolve();
}}> }}>
@ -109,7 +109,7 @@ export class GroupForm extends ModelForm<Group, string> {
const users = Array.from(this.instance?.users || []); const users = Array.from(this.instance?.users || []);
const idx = users.indexOf(user.pk || 0); const idx = users.indexOf(user.pk || 0);
users.splice(idx, 1); users.splice(idx, 1);
this.instance.users = new Set(users); this.instance.users = users;
this.requestUpdate(); this.requestUpdate();
}}> }}>
${user.username} ${user.username}

View File

@ -29,12 +29,12 @@ export class OutpostForm extends ModelForm<Outpost, string> {
send = (data: Outpost): Promise<Outpost> => { send = (data: Outpost): Promise<Outpost> => {
if (this.instance) { if (this.instance) {
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsUpdate({ return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesUpdate({
uuid: this.instance.pk || "", uuid: this.instance.pk || "",
outpostRequest: data outpostRequest: data
}); });
} else { } else {
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsCreate({ return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesCreate({
outpostRequest: data outpostRequest: data
}); });
} }
@ -108,7 +108,7 @@ export class OutpostForm extends ModelForm<Outpost, string> {
<ak-form-element-horizontal <ak-form-element-horizontal
label=${t`Configuration`} label=${t`Configuration`}
name="config"> name="config">
<ak-codemirror mode="yaml" value="${until(new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsDefaultSettings({}).then(config => { <ak-codemirror mode="yaml" value="${until(new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesDefaultSettingsRetrieve().then(config => {
let fc = config.config; let fc = config.config;
if (this.instance) { if (this.instance) {
fc = this.instance.config; fc = this.instance.config;

View File

@ -30,7 +30,7 @@ export class OutpostHealthElement extends LitElement {
firstUpdated(): void { firstUpdated(): void {
if (!this.outpostId) return; if (!this.outpostId) return;
new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsHealth({ new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesHealthList({
uuid: this.outpostId uuid: this.outpostId
}).then(health => { }).then(health => {
this.outpostHealth = health; this.outpostHealth = health;

View File

@ -32,7 +32,7 @@ export class OutpostListPage extends TablePage<Outpost> {
return true; return true;
} }
apiEndpoint(page: number): Promise<AKResponse<Outpost>> { apiEndpoint(page: number): Promise<AKResponse<Outpost>> {
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsList({ return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesList({
ordering: this.order, ordering: this.order,
page: page, page: page,
pageSize: PAGE_SIZE, pageSize: PAGE_SIZE,
@ -76,7 +76,7 @@ export class OutpostListPage extends TablePage<Outpost> {
.obj=${item} .obj=${item}
objectLabel=${t`Outpost`} objectLabel=${t`Outpost`}
.delete=${() => { .delete=${() => {
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsDestroy({ return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesDestroy({
uuid: item.pk || "" uuid: item.pk || ""
}); });
}}> }}>

View File

@ -63,7 +63,7 @@ export class OutpostServiceConnectionListPage extends TablePage<ServiceConnectio
html`${item.verboseName}`, html`${item.verboseName}`,
html`${item.local ? t`Yes` : t`No`}`, html`${item.local ? t`Yes` : t`No`}`,
html`${until( html`${until(
new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllState({ new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllStateRetrieve({
uuid: item.pk || "" uuid: item.pk || ""
}).then((state) => { }).then((state) => {
if (state.healthy) { if (state.healthy) {
@ -113,7 +113,7 @@ export class OutpostServiceConnectionListPage extends TablePage<ServiceConnectio
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i> <i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
</button> </button>
<ul class="pf-c-dropdown__menu" hidden> <ul class="pf-c-dropdown__menu" hidden>
${until(new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllTypes().then((types) => { ${until(new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllTypesList().then((types) => {
return types.map((type) => { return types.map((type) => {
return html`<li> return html`<li>
<ak-forms-modal> <ak-forms-modal>

View File

@ -72,7 +72,7 @@ export class EventMatcherPolicyForm extends ModelForm<EventMatcherPolicy, string
name="action"> name="action">
<select class="pf-c-form-control"> <select class="pf-c-form-control">
<option value="" ?selected=${this.instance?.action === undefined}>---------</option> <option value="" ?selected=${this.instance?.action === undefined}>---------</option>
${until(new EventsApi(DEFAULT_CONFIG).eventsEventsActions().then(actions => { ${until(new EventsApi(DEFAULT_CONFIG).eventsEventsActionsList().then(actions => {
return actions.map(action => { return actions.map(action => {
return html`<option value=${action.component} ?selected=${this.instance?.action === action.component}>${action.name}</option>`; return html`<option value=${action.component} ?selected=${this.instance?.action === action.component}>${action.name}</option>`;
}); });

View File

@ -46,7 +46,7 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
page: page, page: page,
pageSize: PAGE_SIZE, pageSize: PAGE_SIZE,
search: this.search || "", search: this.search || "",
managedIsnull: this.hideManaged ? "true" : undefined, managedIsnull: this.hideManaged ? true : undefined,
}); });
} }
@ -117,7 +117,7 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i> <i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
</button> </button>
<ul class="pf-c-dropdown__menu" hidden> <ul class="pf-c-dropdown__menu" hidden>
${until(new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllTypes().then((types) => { ${until(new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllTypesList().then((types) => {
return types.map((type) => { return types.map((type) => {
return html`<li> return html`<li>
<ak-forms-modal> <ak-forms-modal>

View File

@ -37,7 +37,7 @@ export class OAuth2ProviderViewPage extends LitElement {
}).then((prov) => { }).then((prov) => {
this.provider = prov; this.provider = prov;
}); });
api.providersOauth2SetupUrls({ api.providersOauth2SetupUrlsRetrieve({
id: value id: value
}).then((prov) => { }).then((prov) => {
this.providerUrls = prov; this.providerUrls = prov;

View File

@ -117,7 +117,7 @@ export class SourceListPage extends TablePage<Source> {
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i> <i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
</button> </button>
<ul class="pf-c-dropdown__menu" hidden> <ul class="pf-c-dropdown__menu" hidden>
${until(new SourcesApi(DEFAULT_CONFIG).sourcesAllTypes().then((types) => { ${until(new SourcesApi(DEFAULT_CONFIG).sourcesAllTypesList().then((types) => {
return types.map((type) => { return types.map((type) => {
return html`<li> return html`<li>
<ak-forms-modal> <ak-forms-modal>

View File

@ -196,7 +196,7 @@ export class OAuthSourceForm extends ModelForm<OAuthSource, string> {
} }
this.instance.providerType = selected.value; this.instance.providerType = selected.value;
}}> }}>
${until(new SourcesApi(DEFAULT_CONFIG).sourcesOauthSourceTypes().then(types => { ${until(new SourcesApi(DEFAULT_CONFIG).sourcesOauthSourceTypesList().then(types => {
return types.map(type => { return types.map(type => {
let selected = this.instance?.providerType === type.slug; let selected = this.instance?.providerType === type.slug;
if (!this.instance?.pk) { if (!this.instance?.pk) {

View File

@ -76,7 +76,7 @@ export class EmailStageForm extends ModelForm<EmailStage, string> {
label=${t`SMTP Password`} label=${t`SMTP Password`}
?writeOnly=${this.instance !== undefined} ?writeOnly=${this.instance !== undefined}
name="password"> name="password">
<input type="text" value="${ifDefined(this.instance?.password || "")}" class="pf-c-form-control"> <input type="text" value="" class="pf-c-form-control">
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="useTls"> <ak-form-element-horizontal name="useTls">
<div class="pf-c-check"> <div class="pf-c-check">
@ -156,7 +156,7 @@ export class EmailStageForm extends ModelForm<EmailStage, string> {
?required=${true} ?required=${true}
name="template"> name="template">
<select name="users" class="pf-c-form-control"> <select name="users" class="pf-c-form-control">
${until(new StagesApi(DEFAULT_CONFIG).stagesEmailTemplates().then(templates => { ${until(new StagesApi(DEFAULT_CONFIG).stagesEmailTemplatesList().then(templates => {
return templates.map(template => { return templates.map(template => {
const selected = this.instance?.template === template.name; const selected = this.instance?.template === template.name;
return html`<option value=${ifDefined(template.name)} ?selected=${selected}> return html`<option value=${ifDefined(template.name)} ?selected=${selected}>