/
profilesApi.ts
61 lines (56 loc) · 1.86 KB
/
profilesApi.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
// Copyright 2023 Cognite AS
import { BaseResourceAPI, FilterQuery } from '@cognite/sdk-core';
import {
UserProfileItem,
UserIdentifier,
UserProfilesSearchRequest,
UserProfilesListResponse,
} from '../../types';
export class ProfilesAPI extends BaseResourceAPI<UserProfileItem> {
/**
* [Get the user profile of the principal issuing the request](https://developer.cognite.com/api#tag/User-profiles/operation/getRequesterUserProfile)
*
* ```js
* const response = await client.profiles.me();
* ```
*/
public me = async (): Promise<UserProfileItem> => {
const path = this.url('me');
const response = await this.get<UserProfileItem>(path);
return this.addToMapAndReturn(response.data, response);
};
/**
* [List all user profiles](https://developer.cognite.com/api#tag/User-profiles/operation/listUserProfiles)
*
* ```js
* const response = await client.profiles.list({ limit: 1000, cursor: 'abc' });
* ```
*/
public list = (scope?: FilterQuery): UserProfilesListResponse => {
return this.listEndpoint(this.callListEndpointWithGet, scope);
};
/**
* [Retrieve one or more user profiles by ID](https://developer.cognite.com/api#tag/User-profiles/operation/getUserProfilesByIds)
*
* ```js
* const response = await client.profiles.retrieve([{ userIdentifier: 'abcd' }]);
* ```
*/
public retrieve = async (
userIdentifiers: UserIdentifier[]
): Promise<UserProfileItem[]> => {
return super.retrieveEndpoint(userIdentifiers);
};
/**
* [Search user profiles](https://developer.cognite.com/api#tag/User-profiles/operation/userProfilesSearch)
*
* ```js
* const response = await client.profiles.search({ search: { name: 'John' } });
* ```
*/
public search = async (
query: UserProfilesSearchRequest
): Promise<UserProfileItem[]> => {
return super.searchEndpoint(query);
};
}