1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { AxiosInstance } from "axios";
6 import { ApiActions } from 'services/api/api-actions';
7 import { ApiClientAuthorization } from 'models/api-client-authorization';
8 import { CommonService, ListResults } from 'services/common-service/common-service';
9 import { extractUuidObjectType, ResourceObjectType } from "models/resource";
10 import { FilterBuilder } from "services/api/filter-builder";
12 export class ApiClientAuthorizationService extends CommonService<ApiClientAuthorization> {
13 constructor(serverApi: AxiosInstance, actions: ApiActions) {
14 super(serverApi, "api_client_authorizations", actions);
17 createCollectionSharingToken(uuid: string, expDate: Date | undefined): Promise<ApiClientAuthorization> {
18 if (extractUuidObjectType(uuid) !== ResourceObjectType.COLLECTION) {
19 throw new Error(`UUID ${uuid} is not a collection`);
23 `GET /arvados/v1/collections/${uuid}`,
24 `GET /arvados/v1/collections/${uuid}/`,
25 `GET /arvados/v1/keep_services/accessible`,
28 return expDate !== undefined
29 ? this.create({...data, expiresAt: expDate.toUTCString()})
33 listCollectionSharingTokens(uuid: string): Promise<ListResults<ApiClientAuthorization>> {
34 if (extractUuidObjectType(uuid) !== ResourceObjectType.COLLECTION) {
35 throw new Error(`UUID ${uuid} is not a collection`);
38 filters: new FilterBuilder()
40 `GET /arvados/v1/collections/${uuid}`,
41 `GET /arvados/v1/collections/${uuid}/`,
42 "GET /arvados/v1/keep_services/accessible"