@finos/legend-server-marketplace
Version:
Legend Marketplace server client
65 lines • 3.67 kB
JavaScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AbstractServerClient } from '@finos/legend-shared';
export class LakehouseContractServerClient extends AbstractServerClient {
constructor(config) {
super({
baseUrl: config.baseUrl,
});
}
// auth
_token = (token) => ({
Authorization: `Bearer ${token}`,
});
_contracts = () => `${this.baseUrl}/contracts`;
getDataProducts = (token) => this.get(`${this._contracts()}/dataProducts`, {}, this._token(token));
// ------------------------------------------- Data Contracts -------------------------------------------
_dataContracts = () => `${this.baseUrl}/datacontracts`;
getDataContracts = (token) => this.get(this._dataContracts(), {}, this._token(token));
getDataContract = (id, token) => this.get(`${this._dataContracts()}/${encodeURIComponent(id)}`, {}, this._token(token));
getApprovedUsersForDataContract = (id, token) => this.get(`${this._dataContracts()}/${encodeURIComponent(id)}/approvedUsers`, {}, this._token(token));
getDataContractsFromDID = (body, token) => {
return this.post(`${this._dataContracts()}/query/accessPointsOwnedByDeployments`, body, undefined, this._token(token));
};
getPendingContracts = (user, token) => {
return this.get(`${this._dataContracts()}/pendingContractsForUser`, {}, this._token(token), { user });
};
createContract = (contractRequest, token) => this.post(`${this._dataContracts()}`, contractRequest, undefined, this._token(token));
// ------------------------------------------- Tasks -------------------------------------------
_tasks = () => `${this.baseUrl}/datacontracts/tasks`;
_contract_tasks = () => `${this._tasks()}/query/contract`;
getPendingTasks = (user, token) => {
return this.get(`${this._tasks()}/pending`, {}, this._token(token), {
user,
});
};
getTask = (taskId, token) => {
return this.get(`${this._tasks()}/${encodeURIComponent(taskId)}`, {}, this._token(token), undefined);
};
getContractTasks = (contractId, token) => {
return this.get(`${this._contract_tasks()}/${encodeURIComponent(contractId)}`, {}, this._token(token), {
user: contractId,
});
};
approveTask = (id, token) => this.post(`${this._tasks()}/${encodeURIComponent(id)}/approve`, {}, {}, this._token(token));
denyTask = (id, token) => this.post(`${this._tasks()}/${encodeURIComponent(id)}/deny`, {}, {}, this._token(token));
// --------------------------------------- Subscriptions ---------------------------------------
_subscriptions = () => `${this.baseUrl}/subscriptions`;
getAllSubscriptions = (token) => this.get(this._subscriptions(), {}, this._token(token));
getSubscriptionsForContract = (contractId, token) => this.get(`${this._subscriptions()}/query/contract/${contractId}`, {}, this._token(token));
createSubscription = (input, token) => this.post(this._subscriptions(), input, {}, this._token(token));
}
//# sourceMappingURL=LakehouseContractServerClient.js.map