@migration-planner-ui/agent-client 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@migration-planner-ui/agent-client",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "A client for Migration Planner Agent API",
5
5
  "author": "Jonathan Kilzi <jkilzi@redhat.com>",
6
6
  "repository": {
@@ -1,23 +0,0 @@
1
- import { Either, Credentials, StatusReply, CredentialsError } from "../models";
2
- interface Configuration {
3
- basePath: string;
4
- }
5
- export interface AgentApiInterface {
6
- putCredentials(credentials: Credentials, options?: RequestInit & {
7
- pathParams?: string[];
8
- }): Promise<Either<number, CredentialsError>>;
9
- getStatus(options?: RequestInit): Promise<StatusReply>;
10
- getAgentVersion(): Promise<string>;
11
- getServiceUiUrl(): Promise<string>;
12
- }
13
- export declare class AgentApi implements AgentApiInterface {
14
- private readonly configuration;
15
- constructor(configuration: Configuration);
16
- getStatus(options?: RequestInit): Promise<StatusReply>;
17
- putCredentials(credentials: Credentials, options?: RequestInit & {
18
- pathParams?: string[];
19
- }): Promise<Either<number, CredentialsError>>;
20
- getAgentVersion(): Promise<string>;
21
- getServiceUiUrl(): Promise<string>;
22
- }
23
- export {};
@@ -1,67 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { CredentialsError, } from "../models";
11
- export class AgentApi {
12
- constructor(configuration) {
13
- Object.defineProperty(this, "configuration", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- this.configuration = configuration;
20
- }
21
- getStatus(options) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const request = new Request(this.configuration.basePath + "/status", Object.assign({ method: "GET" }, ((options === null || options === void 0 ? void 0 : options.signal) && { signal: options.signal })));
24
- const response = yield fetch(request);
25
- const statusReply = (yield response.json());
26
- return statusReply;
27
- });
28
- }
29
- putCredentials(credentials, options) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const request = new Request(this.configuration.basePath + "/credentials", Object.assign({ method: "PUT", body: JSON.stringify(credentials) }, ((options === null || options === void 0 ? void 0 : options.signal) && { signal: options.signal })));
32
- const response = yield fetch(request);
33
- if (response.ok) {
34
- return [response.status, null];
35
- }
36
- else {
37
- let message = response.statusText;
38
- const error = new CredentialsError(response.status, message);
39
- if (response.arrayBuffer.length > 0) {
40
- message = yield response.text();
41
- error.message = message;
42
- }
43
- return [null, error];
44
- }
45
- });
46
- }
47
- getAgentVersion() {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const request = new Request(this.configuration.basePath + "/version", {
50
- method: "GET"
51
- });
52
- const response = yield fetch(request);
53
- const statusReply = (yield response.json());
54
- return statusReply.version;
55
- });
56
- }
57
- getServiceUiUrl() {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const request = new Request(this.configuration.basePath + "/url", {
60
- method: "GET"
61
- });
62
- const response = yield fetch(request);
63
- const uiReply = (yield response.json());
64
- return uiReply.url;
65
- });
66
- }
67
- }
@@ -1 +0,0 @@
1
- export * from "./AgentApi";
@@ -1 +0,0 @@
1
- export * from "./AgentApi";
@@ -1,6 +0,0 @@
1
- export interface Credentials {
2
- url: string;
3
- username: string;
4
- password: string;
5
- isDataSharingAllowed?: boolean;
6
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- export declare class CredentialsError extends Error {
2
- codeN?: number;
3
- constructor(code?: number, ...errorArgs: Parameters<ErrorConstructor>);
4
- toString(): string;
5
- get code(): number | undefined;
6
- }
@@ -1,19 +0,0 @@
1
- export class CredentialsError extends Error {
2
- constructor(code, ...errorArgs) {
3
- super(...errorArgs);
4
- Object.defineProperty(this, "codeN", {
5
- enumerable: true,
6
- configurable: true,
7
- writable: true,
8
- value: void 0
9
- });
10
- this.codeN = code;
11
- }
12
- toString() {
13
- const code = this.codeN ? `code=${this.codeN}` : "";
14
- return `${super.toString()} ${code}`;
15
- }
16
- get code() {
17
- return this.codeN;
18
- }
19
- }
@@ -1 +0,0 @@
1
- export type Either<GoodType, BadType> = [GoodType, null] | [null, BadType];
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export declare enum SourceStatus {
2
- SourceStatusError = "error",
3
- SourceStatusGatheringInitialInventory = "gathering-initial-inventory",
4
- SourceStatusNotConnected = "not-connected",
5
- SourceStatusUpToDate = "up-to-date",
6
- SourceStatusWaitingForCredentials = "waiting-for-credentials"
7
- }
@@ -1,8 +0,0 @@
1
- export var SourceStatus;
2
- (function (SourceStatus) {
3
- SourceStatus["SourceStatusError"] = "error";
4
- SourceStatus["SourceStatusGatheringInitialInventory"] = "gathering-initial-inventory";
5
- SourceStatus["SourceStatusNotConnected"] = "not-connected";
6
- SourceStatus["SourceStatusUpToDate"] = "up-to-date";
7
- SourceStatus["SourceStatusWaitingForCredentials"] = "waiting-for-credentials";
8
- })(SourceStatus || (SourceStatus = {}));
@@ -1,5 +0,0 @@
1
- import { SourceStatus } from "./SourceStatus";
2
- export interface StatusReply {
3
- status: SourceStatus;
4
- statusInfo: string;
5
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- export * from "./Credentials";
2
- export * from "./StatusReply";
3
- export * from "./SourceStatus";
4
- export * from "./CredentialsError";
5
- export * from "./Either";
@@ -1,5 +0,0 @@
1
- export * from "./Credentials";
2
- export * from "./StatusReply";
3
- export * from "./SourceStatus";
4
- export * from "./CredentialsError";
5
- export * from "./Either";