Skip to content

Commit

Permalink
Merge branch v3 into PMM-13235-grafana-11
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkubinec committed Jul 18, 2024
2 parents 6d08671 + fe75a73 commit b874fd4
Show file tree
Hide file tree
Showing 74 changed files with 5,075 additions and 2,180 deletions.
6,159 changes: 4,573 additions & 1,586 deletions .betterer.results.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,6 @@ public/app/plugins/**/dist/

# Locally enabling the Go race detector until we can globally do so
.go-race-enabled-locally

# 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
14 changes: 7 additions & 7 deletions public/app/percona/backup/Backup.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum DataModel {
DATA_MODEL_INVALID = 'DATA_MODEL_INVALID',
PHYSICAL = 'PHYSICAL',
LOGICAL = 'LOGICAL',
DATA_MODEL_INVALID = 'DATA_MODEL_UNSPECIFIED',
PHYSICAL = 'DATA_MODEL_PHYSICAL',
LOGICAL = 'DATA_MODEL_LOGICAL',
}

export enum BackupStatus {
Expand Down Expand Up @@ -29,10 +29,10 @@ export enum RetryMode {
}

export enum BackupMode {
INVALID = 'BACKUP_MODE_INVALID',
SNAPSHOT = 'SNAPSHOT',
INCREMENTAL = 'INCREMENTAL',
PITR = 'PITR',
INVALID = 'BACKUP_MODE_UNSPECIFIED',
SNAPSHOT = 'BACKUP_MODE_SNAPSHOT',
INCREMENTAL = 'BACKUP_MODE_INCREMENTAL',
PITR = 'BACKUP_MODE_PITR',
}

export enum BackupType {
Expand Down
Loading

0 comments on commit b874fd4

Please sign in to comment.