Skip to content

Commit

Permalink
refactor(organization): leverage organization property for servingExp…
Browse files Browse the repository at this point in the history
…erimentsAllowed (#841)

refactor(organization): leverage organization for servingExperimentAllowed

BREAKING CHANGE: Removal of getExperimentalStatus
  • Loading branch information
lprovost-coveo authored Aug 1, 2024
1 parent 8ff263b commit bfc43cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
13 changes: 2 additions & 11 deletions src/resources/Organizations/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,9 @@ export default class Organization extends Resource {
return this.api.get<any>(`${Organization.baseUrl}/${organizationId}/additionalinformation`);
}

getExperimentalStatus(organizationId: string = API.orgPlaceholder) {
return this.api.get<boolean>(
`${Organization.baseUrl}/${organizationId}/machinelearning/orgconfiguration/servingExperimentAllowed`,
);
}

updateExperimentalStatus(isAllowed: boolean = false) {
updateExperimentalStatus(allowed: boolean = true) {
return this.api.put<boolean>(
this.buildPath(
`${Organization.baseUrl}/${API.orgPlaceholder}/machinelearning/orgconfiguration/servingExperimentAllowed`,
{isAllowed},
),
`${Organization.baseUrl}/${API.orgPlaceholder}/configuration/servingExperiment?allowed=${allowed}`,
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/resources/Organizations/OrganizationInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export interface OrganizationModel {
readOnly: boolean;
license?: LicenseModel;
organizationStatusModel?: OrganizationsStatusModel;
configuration: {
servingExperimentAllowed: boolean;
};
}

export type AdditionalOrganizationField = 'status' | 'license' | string;
Expand Down
17 changes: 4 additions & 13 deletions src/resources/Organizations/tests/Organizations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,31 +251,22 @@ describe('Organization', () => {
});

describe('experimental status', () => {
it('should make a GET call to the specific Organization url', () => {
const organizationToGetId = 'Organization-to-be-fetched';
organization.getExperimentalStatus(organizationToGetId);
expect(api.get).toHaveBeenCalledTimes(1);
expect(api.get).toHaveBeenCalledWith(
`${Organization.baseUrl}/${organizationToGetId}/machinelearning/orgconfiguration/servingExperimentAllowed`,
);
});

it('should make a PUT call to update experimental status with default false', () => {
it('should make a PUT call to update experimental status with default true', () => {
organization.updateExperimentalStatus();

expect(api.put).toHaveBeenCalledTimes(1);
expect(api.put).toHaveBeenCalledWith(
`${Organization.baseUrl}/{organizationName}/machinelearning/orgconfiguration/servingExperimentAllowed?isAllowed=${false}`,
`${Organization.baseUrl}/{organizationName}/configuration/servingExperiment?allowed=true`,
);
});

it('should make a PUT call to update experimental status with passed value', () => {
const isAllowed = true;
const isAllowed = false;
organization.updateExperimentalStatus(isAllowed);

expect(api.put).toHaveBeenCalledTimes(1);
expect(api.put).toHaveBeenCalledWith(
`${Organization.baseUrl}/{organizationName}/machinelearning/orgconfiguration/servingExperimentAllowed?isAllowed=${true}`,
`${Organization.baseUrl}/{organizationName}/configuration/servingExperiment?allowed=false`,
);
});
});
Expand Down

0 comments on commit bfc43cf

Please sign in to comment.