-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Conflict.ts
66 lines (61 loc) · 2.07 KB
/
Conflict.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { ClientContext } from "../../ClientContext";
import { Constants, getIdFromLink, getPathFromLink, ResourceType } from "../../common";
import { RequestOptions } from "../../request";
import { Container } from "../Container";
import { ConflictDefinition } from "./ConflictDefinition";
import { ConflictResponse } from "./ConflictResponse";
/**
* Use to read or delete a given {@link Conflict} by id.
*
* @see {@link Conflicts} to query or read all conflicts.
*/
export class Conflict {
/**
* Returns a reference URL to the resource. Used for linking in Permissions.
*/
public get url() {
return `/${this.container.url}/${Constants.Path.ConflictsPathSegment}/${this.id}`;
}
/**
* @hidden
* @param container The parent {@link Container}.
* @param id The id of the given {@link Conflict}.
*/
constructor(
public readonly container: Container,
public readonly id: string,
private readonly clientContext: ClientContext
) {}
/**
* Read the {@link ConflictDefinition} for the given {@link Conflict}.
* @param options
*/
public async read(options?: RequestOptions): Promise<ConflictResponse> {
const path = getPathFromLink(this.url, ResourceType.conflicts);
const id = getIdFromLink(this.url);
const response = await this.clientContext.read<ConflictDefinition>({
path,
resourceType: ResourceType.user,
resourceId: id,
options
});
return new ConflictResponse(response.result, response.headers, response.code, this);
}
/**
* Delete the given {@link ConflictDefinition}.
* @param options
*/
public async delete(options?: RequestOptions): Promise<ConflictResponse> {
const path = getPathFromLink(this.url);
const id = getIdFromLink(this.url);
const response = await this.clientContext.delete<ConflictDefinition>({
path,
resourceType: ResourceType.conflicts,
resourceId: id,
options
});
return new ConflictResponse(response.result, response.headers, response.code, this);
}
}