Skip to content

Commit

Permalink
resolve failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 committed Aug 21, 2024
1 parent feeb0cc commit a50ffbb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const AutomatedAnalysisConfigForm: React.FC<AutomatedAnalysisConfigFormPr
context.api
.doGet<EventTemplate[]>(
`targets/${encodeURIComponent(target?.connectUrl || '')}/templates`,
'v1',
'v4',
undefined,
undefined,
true,
Expand Down
2 changes: 1 addition & 1 deletion src/app/Rules/CreateRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const CreateRuleForm: React.FC<CreateRuleFormProps> = (_props) => {
context.api
.doGet<EventTemplate[]>(
`targets/${encodeURIComponent(t.connectUrl)}/templates`,
'v1',
'v4',
undefined,
true,
true,
Expand Down
72 changes: 36 additions & 36 deletions src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class ApiService {
credentials?.username && form.append('username', credentials.username);
credentials?.password && form.append('password', credentials.password);
return this.sendRequest(
'v2',
'v4',
`targets`,
{
method: 'POST',
Expand All @@ -223,7 +223,7 @@ export class ApiService {
}

deleteTarget(target: TargetStub): Observable<boolean> {
return this.sendRequest('v2', `targets/${encodeURIComponent(target.connectUrl)}`, {
return this.sendRequest('v4', `targets/${encodeURIComponent(target.connectUrl)}`, {
method: 'DELETE',
}).pipe(
map((resp) => resp.ok),
Expand All @@ -241,7 +241,7 @@ export class ApiService {

const headers = {};
headers['Content-Type'] = 'application/json';
return this.sendLegacyRequest('v2', 'rules', 'Rule Upload Failed', {
return this.sendLegacyRequest('v4', 'rules', 'Rule Upload Failed', {
method: 'POST',
body: JSON.stringify(rule),
headers: headers,
Expand All @@ -264,7 +264,7 @@ export class ApiService {
createRule(rule: Rule): Observable<boolean> {
const headers = new Headers();
headers.set('Content-Type', 'application/json');
return this.sendRequest('v2', 'rules', {
return this.sendRequest('v4', 'rules', {
method: 'POST',
body: JSON.stringify(rule),
headers,
Expand All @@ -279,7 +279,7 @@ export class ApiService {
const headers = new Headers();
headers.set('Content-Type', 'application/json');
return this.sendRequest(
'v2',
'v4',
`rules/${rule.name}`,
{
method: 'PATCH',
Expand All @@ -295,7 +295,7 @@ export class ApiService {

deleteRule(name: string, clean = true): Observable<boolean> {
return this.sendRequest(
'v2',
'v4',
`rules/${name}`,
{
method: 'DELETE',
Expand Down Expand Up @@ -345,7 +345,7 @@ export class ApiService {

return this.target.target().pipe(
concatMap((target) =>
this.sendRequest('v1', `targets/${encodeURIComponent(target?.connectUrl || '')}/recordings`, {
this.sendRequest('v4', `targets/${encodeURIComponent(target?.connectUrl || '')}/recordings`, {
method: 'POST',
body: form,
}).pipe(
Expand All @@ -372,7 +372,7 @@ export class ApiService {
createSnapshot(): Observable<boolean> {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest('v1', `targets/${encodeURIComponent(target?.connectUrl || '')}/snapshot`, {
this.sendRequest('v4', `targets/${encodeURIComponent(target?.connectUrl || '')}/snapshot`, {
method: 'POST',
}).pipe(
tap((resp) => {
Expand All @@ -391,10 +391,10 @@ export class ApiService {
);
}

createSnapshotV2(): Observable<ActiveRecording | undefined> {
createSnapshotv4(): Observable<ActiveRecording | undefined> {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest('v2', `targets/${encodeURIComponent(target?.connectUrl || '')}/snapshot`, {
this.sendRequest('v4', `targets/${encodeURIComponent(target?.connectUrl || '')}/snapshot`, {
method: 'POST',
}).pipe(
concatMap((resp) => resp.json() as Promise<RecordingResponse>),
Expand All @@ -414,7 +414,7 @@ export class ApiService {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest(
'v1',
'v4',
`targets/${encodeURIComponent(target?.connectUrl || '')}/recordings/${encodeURIComponent(recordingName)}`,
{
method: 'PATCH',
Expand All @@ -432,7 +432,7 @@ export class ApiService {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest(
'v1',
'v4',
`targets/${encodeURIComponent(target?.connectUrl || '')}/recordings/${encodeURIComponent(recordingName)}`,
{
method: 'PATCH',
Expand All @@ -450,7 +450,7 @@ export class ApiService {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest(
'v1',
'v4',
`targets/${encodeURIComponent(target?.connectUrl || '')}/recordings/${encodeURIComponent(recordingName)}`,
{
method: 'DELETE',
Expand Down Expand Up @@ -480,7 +480,7 @@ export class ApiService {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest(
'v1',
'v4',
`targets/${encodeURIComponent(target?.connectUrl || '')}/recordings/${encodeURIComponent(
recordingName,
)}/upload`,
Expand Down Expand Up @@ -616,7 +616,7 @@ export class ApiService {
}

deleteCustomEventTemplate(templateName: string): Observable<boolean> {
return this.sendRequest('v1', `templates/${encodeURIComponent(templateName)}`, {
return this.sendRequest('v4', `templates/${encodeURIComponent(templateName)}`, {
method: 'DELETE',
}).pipe(
map((resp) => resp.ok),
Expand All @@ -634,7 +634,7 @@ export class ApiService {

const body = new window.FormData();
body.append('template', file);
return this.sendLegacyRequest('v1', 'templates', 'Template Upload Failed', {
return this.sendLegacyRequest('v4', 'templates', 'Template Upload Failed', {
body: body,
method: 'POST',
headers: {},
Expand All @@ -657,7 +657,7 @@ export class ApiService {
removeProbes(): Observable<boolean> {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest('v2', `targets/${encodeURIComponent(target?.connectUrl || '')}/probes`, {
this.sendRequest('v4', `targets/${encodeURIComponent(target?.connectUrl || '')}/probes`, {
method: 'DELETE',
}).pipe(
map((resp) => resp.ok),
Expand All @@ -672,7 +672,7 @@ export class ApiService {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest(
'v2',
'v4',
`targets/${encodeURIComponent(target?.connectUrl || '')}/probes/${encodeURIComponent(templateName)}`,
{
method: 'POST',
Expand Down Expand Up @@ -703,7 +703,7 @@ export class ApiService {

const body = new window.FormData();
body.append('probeTemplate', file);
return this.sendLegacyRequest('v2', `probes/${file.name}`, 'Custom Probe Template Upload Failed', {
return this.sendLegacyRequest('v4', `probes/${file.name}`, 'Custom Probe Template Upload Failed', {
method: 'POST',
body: body,
headers: {},
Expand All @@ -724,7 +724,7 @@ export class ApiService {
}

deleteCustomProbeTemplate(templateName: string): Observable<boolean> {
return this.sendRequest('v2', `probes/${encodeURIComponent(templateName)}`, {
return this.sendRequest('v4', `probes/${encodeURIComponent(templateName)}`, {
method: 'DELETE',
}).pipe(
map((resp) => resp.ok),
Expand All @@ -747,7 +747,7 @@ export class ApiService {

doGet<T>(
path: string,
apiVersion: ApiVersion = 'v1',
apiVersion: ApiVersion = 'v4',
params?: URLSearchParams,
suppressNotifications?: boolean,
skipStatusCheck?: boolean,
Expand All @@ -760,7 +760,7 @@ export class ApiService {
}

getProbeTemplates(): Observable<ProbeTemplate[]> {
return this.sendRequest('v2', 'probes', { method: 'GET' }).pipe(
return this.sendRequest('v4', 'probes', { method: 'GET' }).pipe(
concatMap((resp) => resp.json()),
map((response: ProbeTemplateResponse) => response.data.result),
first(),
Expand All @@ -771,7 +771,7 @@ export class ApiService {
return this.target.target().pipe(
concatMap((target) =>
this.sendRequest(
'v2',
'v4',
`targets/${encodeURIComponent(target?.connectUrl || '')}/probes`,
{
method: 'GET',
Expand All @@ -793,7 +793,7 @@ export class ApiService {
skipStatusCheck = false,
): Observable<EventProbe[]> {
return this.sendRequest(
'v2',
'v4',
`targets/${encodeURIComponent(target.connectUrl)}/probes`,
{
method: 'GET',
Expand All @@ -818,7 +818,7 @@ export class ApiService {
headers.set('Content-Type', 'application/json');
const req = () =>
this.sendRequest(
'v2.2',
'v4',
'graphql',
{
method: 'POST',
Expand Down Expand Up @@ -870,7 +870,7 @@ export class ApiService {
}

downloadRule(name: string): void {
this.doGet<RuleResponse>('rules/' + name, 'v2')
this.doGet<RuleResponse>('rules/' + name, 'v4')
.pipe(
first(),
map((resp) => resp.data.result),
Expand All @@ -896,7 +896,7 @@ export class ApiService {
body.append('recording', file);
body.append('labels', JSON.stringify(labels));

return this.sendLegacyRequest('v1', 'recordings', 'Recording Upload Failed', {
return this.sendLegacyRequest('v4', 'recordings', 'Recording Upload Failed', {
method: 'POST',
body: body,
headers: {},
Expand Down Expand Up @@ -930,7 +930,7 @@ export class ApiService {

const body = new window.FormData();
body.append('cert', file);
return this.sendLegacyRequest('v2', 'certificates', 'Certificate Upload Failed', {
return this.sendLegacyRequest('v4', 'certificates', 'Certificate Upload Failed', {
method: 'POST',
body,
headers: {},
Expand Down Expand Up @@ -1059,7 +1059,7 @@ export class ApiService {
body.append('username', username);
body.append('password', password);

return this.sendRequest('v2.2', 'credentials', {
return this.sendRequest('v4', 'credentials', {
method: 'POST',
body,
}).pipe(
Expand All @@ -1070,7 +1070,7 @@ export class ApiService {
}

getCredential(id: number): Observable<MatchedCredential> {
return this.sendRequest('v2.2', `credentials/${id}`, {
return this.sendRequest('v4', `credentials/${id}`, {
method: 'GET',
}).pipe(
concatMap((resp) => resp.json()),
Expand All @@ -1081,7 +1081,7 @@ export class ApiService {

getCredentials(suppressNotifications = false, skipStatusCheck = false): Observable<StoredCredential[]> {
return this.sendRequest(
'v2.2',
'v4',
`credentials`,
{
method: 'GET',
Expand All @@ -1097,7 +1097,7 @@ export class ApiService {
}

deleteCredentials(id: number): Observable<boolean> {
return this.sendRequest('v2.2', `credentials/${id}`, {
return this.sendRequest('v4', `credentials/${id}`, {
method: 'DELETE',
}).pipe(
map((resp) => resp.ok),
Expand All @@ -1107,7 +1107,7 @@ export class ApiService {

getRules(suppressNotifications = false, skipStatusCheck = false): Observable<Rule[]> {
return this.sendRequest(
'v2',
'v4',
'rules',
{
method: 'GET',
Expand Down Expand Up @@ -1347,7 +1347,7 @@ export class ApiService {
getTargetActiveRecordings(target: TargetStub): Observable<ActiveRecording[]> {
return this.doGet<ActiveRecording[]>(
`targets/${encodeURIComponent(target.connectUrl)}/recordings`,
'v1',
'v4',
undefined,
true,
true,
Expand All @@ -1357,7 +1357,7 @@ export class ApiService {
getTargetEventTemplates(target: TargetStub): Observable<EventTemplate[]> {
return this.doGet<EventTemplate[]>(
`targets/${encodeURIComponent(target.connectUrl)}/templates`,
'v1',
'v4',
undefined,
true,
true,
Expand All @@ -1367,7 +1367,7 @@ export class ApiService {
getTargetEventTypes(target: TargetStub): Observable<EventType[]> {
return this.doGet<EventType[]>(
`targets/${encodeURIComponent(target.connectUrl)}/events`,
'v1',
'v4',
undefined,
true,
true,
Expand Down
2 changes: 1 addition & 1 deletion src/app/Shared/Services/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { AlertVariant } from '@patternfly/react-core';
import _ from 'lodash';
import { Observable } from 'rxjs';

export type ApiVersion = 'v1' | 'v2' | 'v2.1' | 'v2.2' | 'v2.3' | 'v2.4' | 'v3' | 'beta';
export type ApiVersion = 'v4' | 'beta';

// ======================================
// Common Resources
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Entity/EntityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export const TargetResources: React.FC<{ targetNode: TargetNode }> = ({ targetNo
const checkIfAgentDetected = React.useCallback(() => {
addSubscription(
context.api
.doGet(`targets/${encodeURIComponent(target.connectUrl)}/probes`, 'v2', undefined, true, true)
.doGet(`targets/${encodeURIComponent(target.connectUrl)}/probes`, 'v4', undefined, true, true)
.pipe(
concatMap(() => of(true)),
catchError(() => of(false)),
Expand Down

0 comments on commit a50ffbb

Please sign in to comment.