Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-12710: Api Breaking Changes #742

Merged
merged 58 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8c54b59
Actions, Services , Agents, Nodes Apis changes
doracretu3pillar Mar 25, 2024
097f67b
Update ServicesService
doracretu3pillar Mar 28, 2024
41d5983
Merge branch 'v3' into PMM-12710-API-braking-changes
doracretu3pillar Apr 4, 2024
559a54d
Backups, Alerting, User services api updates
doracretu3pillar Apr 15, 2024
a25a497
Merge branch 'PMM-12710-API-braking-changes' of https://github.com/pe…
doracretu3pillar Apr 15, 2024
0921f59
ScheduledBakups, BackupInventory, Backup service
doracretu3pillar Apr 16, 2024
1591e20
LocationsService api changes
doracretu3pillar Apr 17, 2024
60fd7d3
RoleService, DumpsService, RestoreHistoryService api changes
doracretu3pillar Apr 17, 2024
08ad920
PlatformService api changes
doracretu3pillar Apr 17, 2024
114c09a
Nodes, Agents , CheckService API changes
doracretu3pillar Apr 18, 2024
ec8a3d1
Modified ChangeScheduled api
doracretu3pillar Apr 18, 2024
a1bfc4b
Platform, Entitlements service API
doracretu3pillar Apr 18, 2024
adec798
Management services APIs
doracretu3pillar Apr 24, 2024
e27b080
Discover services APIs
doracretu3pillar Apr 24, 2024
13b3bc3
Merge branch 'v3' into PMM-12710-API-braking-changes
doracretu3pillar Apr 25, 2024
af8d3f4
Typescript fixes
doracretu3pillar Apr 25, 2024
c37ff1c
Merge branch 'v3' into PMM-12710-API-braking-changes
matejkubinec Apr 30, 2024
574cff1
PMM-12710 Extend api helper
matejkubinec May 2, 2024
0acc8f8
PMM-12710 Reintroduce cancel token
matejkubinec May 2, 2024
579b8fd
PMM-12710 Update settings api calls
matejkubinec May 3, 2024
2c14e2e
PMM-12710 Use correct url for backups
matejkubinec May 3, 2024
23f0514
PMM-12710 Fix & ajdust inventory api connections
matejkubinec May 7, 2024
1457953
PMM-12710 Fix advisors
matejkubinec May 9, 2024
e11c996
PMM-12710 Update service types
matejkubinec May 9, 2024
b3d8e13
PMM-12710 Update PT Summary
matejkubinec May 9, 2024
a6a9ef7
Merge branch 'v3' into PMM-12710-API-braking-changes
matejkubinec May 9, 2024
7d88aeb
PMM-12710 Refactor query parameters
matejkubinec May 10, 2024
e4e7093
PMM-12710 Update betterer file
matejkubinec May 10, 2024
79c4a05
PMM-12710 Correctly handle custom labels edit
matejkubinec May 10, 2024
9b36099
PMM-12710 Update betterrer results
matejkubinec May 10, 2024
2b3e3ec
PMM-12710 Update ignore files
matejkubinec May 13, 2024
1020f9e
Fixed backups api call
doracretu3pillar May 15, 2024
c9750fa
Merge branch 'v3' into PMM-12710-API-braking-changes
doracretu3pillar May 28, 2024
aa3ec15
Fix after PR review
doracretu3pillar May 29, 2024
7f853e6
Merge branch 'PMM-12710-API-braking-changes' of https://github.com/pe…
doracretu3pillar May 29, 2024
d437615
Fixed prettier
doracretu3pillar May 29, 2024
35e0d33
Fixed tests
doracretu3pillar May 29, 2024
4abedb5
Fixed prettier
doracretu3pillar May 29, 2024
4c4acd6
Fixed test in AddRemoteInstance.service.test
doracretu3pillar May 29, 2024
5617302
Fixed after review
doracretu3pillar Jun 3, 2024
e52f9d3
Removed the body from InventoryService
doracretu3pillar Jun 3, 2024
aa234c5
Added payload back to the AlertRule list API
doracretu3pillar Jun 3, 2024
5149089
Force true to removeNode
doracretu3pillar Jun 3, 2024
678f478
PMM-12710 Remove identifier prefixes
YashSartanpara1 Jun 11, 2024
714b631
PMM-12710 run prettier
YashSartanpara1 Jun 11, 2024
b613c76
Fixed payload for AlertRuleTemplate and Check services
doracretu3pillar Jun 11, 2024
e6afc57
PMM-12710 Remove redundant variable
YashSartanpara1 Jun 13, 2024
e39a3c8
Fixed APIs after testing
doracretu3pillar Jun 20, 2024
05cc9e3
Merge branch 'v3' into PMM-12710-API-braking-changes
doracretu3pillar Jun 20, 2024
c417af7
Fixed prettier
doracretu3pillar Jun 20, 2024
c9781db
Added force to Service services
doracretu3pillar Jun 20, 2024
b2b27ed
Merge branch 'v3' into PMM-12710-API-braking-changes
doracretu3pillar Jun 25, 2024
1ececc5
Fixed error message banner
doracretu3pillar Jul 1, 2024
daa3d40
Revert changes
doracretu3pillar Jul 1, 2024
65ad0d3
Fixed error message banner
doracretu3pillar Jul 1, 2024
21e3196
Modify the backup mode enum
doracretu3pillar Jul 2, 2024
39f7546
Fixed DataModel enum
doracretu3pillar Jul 2, 2024
62d03c8
Check if axios is cancel, don't show the error
doracretu3pillar Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .betterer.results.json
Original file line number Diff line number Diff line change
Expand Up @@ -5366,6 +5366,12 @@
"count": 1
}
],
"/public/app/percona/integrated-alerting/components/TemplateForm/EvaluateEvery/EvaluateEvery.styles.ts": [
{
"message": "Styles should be written using objects.",
"count": 1
}
],
"/public/app/plugins/datasource/alertmanager/DataSource.ts": [
{
"message": "Unexpected any. Specify a different type.",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,6 @@ public/app/plugins/**/dist/
# Ignore transpiled JavaScript resulting from the generate-transformations.ts script.
/public/app/features/transformers/docs/*.js
/scripts/docs/generate-transformations.js

# NX
.nx/cache
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.nx
.git
.github
.yarn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('AddRemoteInstanceService:: ', () => {
},
add_node: {
node_name: 'localhost',
node_type: 'REMOTE_NODE',
node_type: 'NODE_TYPE_REMOTE_NODE',
},
listen_port: '80',
metrics_mode: 1,
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('AddRemoteInstanceService:: ', () => {
},
add_node: {
node_name: 'localhost',
node_type: 'REMOTE_NODE',
node_type: 'NODE_TYPE_REMOTE_NODE',
},
pmm_agent_id: 'pmm-server',
port: '80',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,69 +24,67 @@ import {
HaProxyPayload,
ProxySQLPayload,
MongoDBPayload,
AddServicePayload,
} from './AddRemoteInstance.types';

const BASE_URL = '/services';

class AddRemoteInstanceService {
static async addMysql(body: MySQLPayload, token?: CancelToken) {
return apiManagement.post<MySQLInstanceResponse | ErrorResponse, RemoteInstancePayload>(
'/MySQL/Add',
body,
return apiManagement.post<MySQLInstanceResponse | ErrorResponse, AddServicePayload>(
BASE_URL,
{ mysql: body },
false,
token
);
}

static async addPostgresql(body: PostgreSQLPayload, token?: CancelToken) {
return apiManagement.post<PostgreSQLInstanceResponse | ErrorResponse, RemoteInstancePayload>(
'/PostgreSQL/Add',
body,
return apiManagement.post<PostgreSQLInstanceResponse | ErrorResponse, AddServicePayload>(
BASE_URL,
{ postgresql: body },
false,
token
);
}

static async addProxysql(body: ProxySQLPayload, token?: CancelToken) {
return apiManagement.post<ProxySQLInstanceResponse | ErrorResponse, RemoteInstancePayload>(
'/ProxySQL/Add',
body,
return apiManagement.post<ProxySQLInstanceResponse | ErrorResponse, AddServicePayload>(
BASE_URL,
{ proxysql: body },
false,
token
);
}

static async addHaproxy(body: HaProxyPayload, token?: CancelToken) {
return apiManagement.post<AddHaProxyResponse | ErrorResponse, RemoteInstancePayload>(
'/HAProxy/Add',
body,
return apiManagement.post<AddHaProxyResponse | ErrorResponse, AddServicePayload>(
BASE_URL,
{ haproxy: body },
false,
token
);
}

static async addMongodb(body: MongoDBPayload, token?: CancelToken) {
return apiManagement.post<AddMongoDbResponse | ErrorResponse, RemoteInstancePayload>(
'/MongoDB/Add',
body,
return apiManagement.post<AddMongoDbResponse | ErrorResponse, AddServicePayload>(
BASE_URL,
{ mongodb: body },
false,
token
);
}

static async addRDS(body: RDSPayload, token?: CancelToken) {
return apiManagement.post<AddRDSResponse | ErrorResponse, RemoteInstancePayload>('/RDS/Add', body, false, token);
return apiManagement.post<AddRDSResponse | ErrorResponse, AddServicePayload>(BASE_URL, { rds: body }, false, token);
}

static async addAzure(body: MSAzurePayload, token?: CancelToken) {
return apiManagement.post<{} | ErrorResponse, RemoteInstancePayload>(
'/azure/AzureDatabase/Add',
body,
false,
token
);
return apiManagement.post<{} | ErrorResponse, RemoteInstancePayload>(`${BASE_URL}/azure`, body, false, token);
}

static async addExternal(body: ExternalPayload, token?: CancelToken) {
return apiManagement.post<AddExternalResponse, ExternalPayload>('/External/Add', body, false, token);
return apiManagement.post<AddExternalResponse, AddServicePayload>(BASE_URL, { external: body }, false, token);
}

static addRemote(type: InstanceAvailableType, data: RemoteInstancePayload, token?: CancelToken) {
Expand Down Expand Up @@ -147,7 +145,7 @@ export const toPayload = (values: any, discoverName?: string, type?: InstanceAva
if (!values.isAzure && data.add_node === undefined) {
data.add_node = {
node_name: data.service_name,
node_type: 'REMOTE_NODE',
node_type: 'NODE_TYPE_REMOTE_NODE',
};
}

Expand Down Expand Up @@ -214,7 +212,7 @@ export const toExternalServicePayload = (values: any): ExternalPayload => {
if (data.add_node === undefined) {
data.add_node = {
node_name: data.service_name,
node_type: 'REMOTE_NODE',
node_type: 'NODE_TYPE_REMOTE_NODE',
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Databases } from 'app/percona/shared/core';

import { DiscoverRDSEngine } from '../Discovery/Discovery.types';

import { getInstanceData } from './AddRemoteInstance.tools';

describe('Get instance data:: ', () => {
Expand Down Expand Up @@ -41,7 +43,7 @@ describe('Get instance data:: ', () => {
};
const testInstance = {
instanceType: 'PostgreSQL',
discoverName: 'DISCOVER_RDS_POSTGRESQL',
discoverName: DiscoverRDSEngine.POSTGRESQL,
remoteInstanceCredentials: {
isRDS: true,
address: 'test address',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Databases } from 'app/percona/shared/core';
import { logger } from 'app/percona/shared/helpers/logger';

import { InstanceAvailableType, INSTANCE_TYPES_LABELS } from '../../panel.types';
import { DiscoverAzureDatabaseType, DiscoverRDSEngine } from '../Discovery/Discovery.types';

import { DEFAULT_PORTS } from './AddRemoteInstance.constants';
import { InstanceData } from './AddRemoteInstance.types';
Expand Down Expand Up @@ -31,19 +32,19 @@ const getAzureCredentials = (credentials: any, instanceType: string) => {
switch (instanceType) {
case Databases.postgresql:
instance.instanceType = INSTANCE_TYPES_LABELS[Databases.postgresql];
instance.discoverName = 'DISCOVER_AZURE_DATABASE_TYPE_POSTGRESQL';
instance.discoverName = DiscoverAzureDatabaseType.POSTGRESQL;
instance.remoteInstanceCredentials.port =
instance.remoteInstanceCredentials.port || DEFAULT_PORTS[Databases.postgresql];
break;
case Databases.mysql:
instance.instanceType = INSTANCE_TYPES_LABELS[Databases.mysql];
instance.discoverName = 'DISCOVER_AZURE_DATABASE_TYPE_MYSQL';
instance.discoverName = DiscoverAzureDatabaseType.MYSQL;
instance.remoteInstanceCredentials.port =
instance.remoteInstanceCredentials.port || DEFAULT_PORTS[Databases.mysql];
break;
case Databases.mariadb:
instance.instanceType = INSTANCE_TYPES_LABELS[Databases.mariadb];
instance.discoverName = 'DISCOVER_AZURE_DATABASE_TYPE_MARIADB';
instance.discoverName = DiscoverAzureDatabaseType.MARIADB;
instance.remoteInstanceCredentials.port =
instance.remoteInstanceCredentials.port || DEFAULT_PORTS[Databases.mysql];
break;
Expand Down Expand Up @@ -72,13 +73,13 @@ const getRDSCredentials = (credentials: any, instanceType: InstanceAvailableType
switch (instanceType) {
case Databases.postgresql:
instance.instanceType = INSTANCE_TYPES_LABELS[Databases.postgresql];
instance.discoverName = 'DISCOVER_RDS_POSTGRESQL';
instance.discoverName = DiscoverRDSEngine.POSTGRESQL;
instance.remoteInstanceCredentials.port =
instance.remoteInstanceCredentials.port || DEFAULT_PORTS[Databases.postgresql];
break;
case Databases.mysql:
instance.instanceType = INSTANCE_TYPES_LABELS[Databases.mysql];
instance.discoverName = 'DISCOVER_RDS_MYSQL';
instance.discoverName = DiscoverRDSEngine.MYSQL;
instance.remoteInstanceCredentials.port =
instance.remoteInstanceCredentials.port || DEFAULT_PORTS[Databases.mysql];
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ export type RemoteInstancePayload =
| MongoDBPayload
| ExternalPayload;

export type AddServicePayload = {
mysql?: MySQLPayload;
mongodb?: MongoDBPayload;
postgresql?: PostgreSQLPayload;
proxysql?: ProxySQLPayload;
haproxy?: HaProxyPayload;
external?: ExternalPayload;
rds?: RDSPayload;
};

export interface ErrorResponse {
error: string;
code: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DiscoveryService {
token?: CancelToken
) {
return apiManagement.post<AzureDatabaseInstances, AzureCredentialsForm>(
'/azure/AzureDatabase/Discover',
'/services:discoverAzure',
{
azure_client_id,
azure_client_secret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button } from '@grafana/ui';
import { InstanceAvailableType, SelectInstance } from 'app/percona/add-instance/panel.types';
import { DATABASE_LABELS, Databases } from 'app/percona/shared/core';

import { DiscoverAzureDatabaseType } from '../../../Discovery/Discovery.types';
import { Instance } from '../../Discovery.types';
import { AzureCredentialsForm } from '../Credentials/Credentials.types';

Expand All @@ -13,13 +14,13 @@ import { styles } from './Instances.styles';

const getEngineType = (type?: string) => {
switch (type) {
case 'DISCOVER_AZURE_DATABASE_TYPE_MYSQL':
case DiscoverAzureDatabaseType.MYSQL:
return DATABASE_LABELS[Databases.mysql];
case 'DISCOVER_AZURE_DATABASE_TYPE_MARIADB':
case DiscoverAzureDatabaseType.MARIADB:
return DATABASE_LABELS[Databases.mariadb];
case 'DISCOVER_AZURE_DATABASE_TYPE_POSTGRESQL':
case DiscoverAzureDatabaseType.POSTGRESQL:
return DATABASE_LABELS[Databases.postgresql];
case 'DISCOVER_AZURE_DATABASE_INVALID':
case DiscoverAzureDatabaseType.INVALID:
return 'Unknown type';
default:
return 'Unknown type';
Expand All @@ -28,10 +29,10 @@ const getEngineType = (type?: string) => {

const getDatabaseType = (type?: string): InstanceAvailableType => {
switch (type) {
case 'DISCOVER_AZURE_DATABASE_TYPE_MYSQL':
case 'DISCOVER_AZURE_DATABASE_TYPE_MARIADB':
case DiscoverAzureDatabaseType.MYSQL:
case DiscoverAzureDatabaseType.MARIADB:
return Databases.mysql;
case 'DISCOVER_AZURE_DATABASE_TYPE_POSTGRESQL':
case DiscoverAzureDatabaseType.POSTGRESQL:
return Databases.postgresql;
default:
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DiscoveryService {
) {
return apiManagement
.post<RDSInstances, RDSCredentialsForm>(
'/RDS/Discover',
'/services:discoverRDS',
{
aws_access_key,
aws_secret_key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ export interface Instance {
export interface RDSInstances {
rds_instances: Instance[];
}

export enum DiscoverRDSEngine {
POSTGRESQL = 'DISCOVER_RDS_ENGINE_POSTGRESQL',
MYSQL = 'DISCOVER_RDS_ENGINE_MYSQL',
UNSPECIFIED = 'DISCOVER_RDS_ENGINE_UNSPECIFIED',
}

export enum DiscoverAzureDatabaseType {
POSTGRESQL = 'DISCOVER_AZURE_DATABASE_TYPE_POSTGRESQL',
MYSQL = 'DISCOVER_AZURE_DATABASE_TYPE_MYSQL',
MARIADB = 'DISCOVER_AZURE_DATABASE_TYPE_MARIADB',
INVALID = 'DISCOVER_AZURE_DATABASE_INVALID',
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { Button } from '@grafana/ui';
import { SelectInstance } from 'app/percona/add-instance/panel.types';
import { DATABASE_LABELS, Databases } from 'app/percona/shared/core';

import { Instance } from '../../Discovery.types';
import { DiscoverRDSEngine, Instance } from '../../Discovery.types';
import { RDSCredentialsForm } from '../Credentials/Credentials.types';

import { styles } from './Instances.styles';

const getEngineType = (type?: string) => {
switch (type) {
case 'DISCOVER_RDS_MYSQL':
case DiscoverRDSEngine.MYSQL:
return DATABASE_LABELS[Databases.mysql];
case 'DISCOVER_RDS_POSTGRESQL':
case DiscoverRDSEngine.POSTGRESQL:
return DATABASE_LABELS[Databases.postgresql];
case 'DISCOVER_RDS_INVALID':
case DiscoverRDSEngine.UNSPECIFIED:
return 'Unknown type';
default:
return 'Unknown type';
Expand All @@ -25,9 +25,9 @@ const getEngineType = (type?: string) => {

const getDatabaseType = (type?: string) => {
switch (type) {
case 'DISCOVER_RDS_MYSQL':
case DiscoverRDSEngine.MYSQL:
return Databases.mysql;
case 'DISCOVER_RDS_POSTGRESQL':
case DiscoverRDSEngine.POSTGRESQL:
return Databases.postgresql;
default:
return '';
Expand Down
8 changes: 4 additions & 4 deletions public/app/percona/backup/Backup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getCronStringFromValues } from '../shared/helpers/cron/cron';
import { BackupMode, BackupType, DataModel, RetryMode } from './Backup.types';
import { AddBackupFormProps } from './components/AddBackupPage/AddBackupPage.types';

const BASE_URL = '/v1/management/backup/Backups';
const BASE_URL = '/v1/backups';

export const BackupService = {
backup(values: AddBackupFormProps, token?: CancelToken) {
Expand Down Expand Up @@ -98,7 +98,7 @@ export const BackupService = {
token?: CancelToken
) {
return api.post(
`${BASE_URL}/Start`,
`${BASE_URL}:start`,
{
service_id: serviceId,
location_id: locationId,
Expand Down Expand Up @@ -127,7 +127,7 @@ export const BackupService = {
dataModel: DataModel,
folder: string
) {
return api.post(`${BASE_URL}/Schedule`, {
return api.post(`${BASE_URL}:schedule`, {
service_id: serviceId,
location_id: locationId,
cron_expression: cronExpression,
Expand All @@ -152,7 +152,7 @@ export const BackupService = {
retryTimes: number,
retention: number
) {
return api.post(`${BASE_URL}/ChangeScheduled`, {
return api.put(`${BASE_URL}:changeScheduled`, {
scheduled_backup_id: id,
enabled,
cron_expression: cronExpression,
Expand Down
Loading
Loading