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/tokens", TokenViewSet)
router.register("outposts/outposts", OutpostViewSet)
router.register("outposts/instances", OutpostViewSet)
router.register("outposts/service_connections/all", ServiceConnectionViewSet)
router.register("outposts/service_connections/docker", DockerServiceConnectionViewSet)

View file

@ -4061,248 +4061,6 @@ paths:
schema:
$ref: '#/components/schemas/LDAPOutpostConfig'
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/:
get:
operationId: outposts_proxy_list

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -38,7 +38,7 @@ export class GroupForm extends ModelForm<Group, string> {
groupRequest: data
});
} 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({
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
const ids = items.map(u => u.pk || 0);
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();
return Promise.resolve();
}}>
@ -109,7 +109,7 @@ export class GroupForm extends ModelForm<Group, string> {
const users = Array.from(this.instance?.users || []);
const idx = users.indexOf(user.pk || 0);
users.splice(idx, 1);
this.instance.users = new Set(users);
this.instance.users = users;
this.requestUpdate();
}}>
${user.username}

View file

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

View file

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

View file

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

View file

@ -63,7 +63,7 @@ export class OutpostServiceConnectionListPage extends TablePage<ServiceConnectio
html`${item.verboseName}`,
html`${item.local ? t`Yes` : t`No`}`,
html`${until(
new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllState({
new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllStateRetrieve({
uuid: item.pk || ""
}).then((state) => {
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>
</button>
<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 html`<li>
<ak-forms-modal>

View file

@ -72,7 +72,7 @@ export class EventMatcherPolicyForm extends ModelForm<EventMatcherPolicy, string
name="action">
<select class="pf-c-form-control">
<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 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,
pageSize: PAGE_SIZE,
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>
</button>
<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 html`<li>
<ak-forms-modal>

View file

@ -37,7 +37,7 @@ export class OAuth2ProviderViewPage extends LitElement {
}).then((prov) => {
this.provider = prov;
});
api.providersOauth2SetupUrls({
api.providersOauth2SetupUrlsRetrieve({
id: value
}).then((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>
</button>
<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 html`<li>
<ak-forms-modal>

View file

@ -196,7 +196,7 @@ export class OAuthSourceForm extends ModelForm<OAuthSource, string> {
}
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 => {
let selected = this.instance?.providerType === type.slug;
if (!this.instance?.pk) {

View file

@ -76,7 +76,7 @@ export class EmailStageForm extends ModelForm<EmailStage, string> {
label=${t`SMTP Password`}
?writeOnly=${this.instance !== undefined}
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 name="useTls">
<div class="pf-c-check">
@ -156,7 +156,7 @@ export class EmailStageForm extends ModelForm<EmailStage, string> {
?required=${true}
name="template">
<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 => {
const selected = this.instance?.template === template.name;
return html`<option value=${ifDefined(template.name)} ?selected=${selected}>