1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-02 08:40:08 +01:00

policy apis

This commit is contained in:
Kyle Spearrin 2020-01-15 11:24:00 -05:00
parent 844699f1a4
commit f66de2207c
4 changed files with 63 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import { PasswordHintRequest } from '../models/request/passwordHintRequest';
import { PasswordRequest } from '../models/request/passwordRequest';
import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest';
import { PaymentRequest } from '../models/request/paymentRequest';
import { PolicyRequest } from '../models/request/policyRequest';
import { PreloginRequest } from '../models/request/preloginRequest';
import { RegisterRequest } from '../models/request/registerRequest';
import { SeatRequest } from '../models/request/seatRequest';
@ -80,6 +81,7 @@ import {
OrganizationUserUserDetailsResponse,
} from '../models/response/organizationUserResponse';
import { PaymentResponse } from '../models/response/paymentResponse';
import { PolicyResponse } from '../models/response/policyResponse';
import { PreloginResponse } from '../models/response/preloginResponse';
import { ProfileResponse } from '../models/response/profileResponse';
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
@ -186,6 +188,12 @@ export abstract class ApiService {
deleteGroup: (organizationId: string, id: string) => Promise<any>;
deleteGroupUser: (organizationId: string, id: string, organizationUserId: string) => Promise<any>;
getPolicy: (organizationId: string, id: string) => Promise<PolicyResponse>;
getPolicies: (organizationId: string) => Promise<ListResponse<PolicyResponse>>;
postPolicy: (organizationId: string, request: PolicyRequest) => Promise<PolicyResponse>;
putPolicy: (organizationId: string, id: string, request: PolicyRequest) => Promise<PolicyResponse>;
deletePolicy: (organizationId: string, id: string) => Promise<any>;
getOrganizationUser: (organizationId: string, id: string) => Promise<OrganizationUserDetailsResponse>;
getOrganizationUserGroups: (organizationId: string, id: string) => Promise<string[]>;
getOrganizationUsers: (organizationId: string) => Promise<ListResponse<OrganizationUserUserDetailsResponse>>;

View File

@ -0,0 +1,7 @@
import { PolicyType } from '../../enums/policyType';
export class PolicyRequest {
type: PolicyType;
enabled: boolean;
data: any;
}

View File

@ -0,0 +1,20 @@
import { BaseResponse } from './baseResponse';
import { PolicyType } from '../../enums/policyType';
export class PolicyResponse extends BaseResponse {
id: string;
organizationId: string;
type: PolicyType;
data: any;
enabled: boolean;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.organizationId = this.getResponseProperty('OrganizationId');
this.type = this.getResponseProperty('Type');
this.data = this.getResponseProperty('Data');
this.enabled = this.getResponseProperty('Enabled');
}
}

View File

@ -39,6 +39,7 @@ import { PasswordHintRequest } from '../models/request/passwordHintRequest';
import { PasswordRequest } from '../models/request/passwordRequest';
import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest';
import { PaymentRequest } from '../models/request/paymentRequest';
import { PolicyRequest } from '../models/request/policyRequest';
import { PreloginRequest } from '../models/request/preloginRequest';
import { RegisterRequest } from '../models/request/registerRequest';
import { SeatRequest } from '../models/request/seatRequest';
@ -87,6 +88,7 @@ import {
OrganizationUserUserDetailsResponse,
} from '../models/response/organizationUserResponse';
import { PaymentResponse } from '../models/response/paymentResponse';
import { PolicyResponse } from '../models/response/policyResponse';
import { PreloginResponse } from '../models/response/preloginResponse';
import { ProfileResponse } from '../models/response/profileResponse';
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
@ -549,6 +551,32 @@ export class ApiService implements ApiServiceAbstraction {
'/organizations/' + organizationId + '/groups/' + id + '/user/' + organizationUserId, null, true, false);
}
// Policy APIs
async getPolicy(organizationId: string, id: string): Promise<PolicyResponse> {
const r = await this.send('GET', '/organizations/' + organizationId + '/policies/' + id, null, true, true);
return new PolicyResponse(r);
}
async getPolicies(organizationId: string): Promise<ListResponse<PolicyResponse>> {
const r = await this.send('GET', '/organizations/' + organizationId + '/policies', null, true, true);
return new ListResponse(r, PolicyResponse);
}
async postPolicy(organizationId: string, request: PolicyRequest): Promise<PolicyResponse> {
const r = await this.send('POST', '/organizations/' + organizationId + '/policies', request, true, true);
return new PolicyResponse(r);
}
async putPolicy(organizationId: string, id: string, request: PolicyRequest): Promise<PolicyResponse> {
const r = await this.send('PUT', '/organizations/' + organizationId + '/policies/' + id, request, true, true);
return new PolicyResponse(r);
}
deletePolicy(organizationId: string, id: string): Promise<any> {
return this.send('DELETE', '/organizations/' + organizationId + '/policies/' + id, null, true, false);
}
// Organization User APIs
async getOrganizationUser(organizationId: string, id: string): Promise<OrganizationUserDetailsResponse> {