1
- import { CreateDatabaseDto } from 'src/modules/database/dto/create.database.dto' ;
2
- import { PartialType } from '@nestjs/swagger' ;
1
+ import { ApiPropertyOptional , getSchemaPath } from '@nestjs/swagger' ;
3
2
import {
4
- IsInt , IsString , MaxLength , ValidateIf ,
3
+ IsBoolean ,
4
+ IsInt , IsNotEmpty , IsNotEmptyObject , IsOptional , IsString , MaxLength , Min , ValidateIf , ValidateNested ,
5
5
} from 'class-validator' ;
6
+ import { CreateCaCertificateDto } from 'src/modules/certificate/dto/create.ca-certificate.dto' ;
7
+ import { UseCaCertificateDto } from 'src/modules/certificate/dto/use.ca-certificate.dto' ;
8
+ import { Expose , Type } from 'class-transformer' ;
9
+ import { caCertTransformer } from 'src/modules/certificate/transformers/ca-cert.transformer' ;
10
+ import { Default } from 'src/common/decorators' ;
11
+ import { CreateClientCertificateDto } from 'src/modules/certificate/dto/create.client-certificate.dto' ;
12
+ import { clientCertTransformer } from 'src/modules/certificate/transformers/client-cert.transformer' ;
13
+ import { UseClientCertificateDto } from 'src/modules/certificate/dto/use.client-certificate.dto' ;
14
+ import { SentinelMaster } from 'src/modules/redis-sentinel/models/sentinel-master' ;
15
+ import { CreateDatabaseDto } from 'src/modules/database/dto/create.database.dto' ;
6
16
7
- export class UpdateDatabaseDto extends PartialType ( CreateDatabaseDto ) {
17
+ export class UpdateDatabaseDto extends CreateDatabaseDto {
8
18
@ValidateIf ( ( object , value ) => value !== undefined )
9
19
@IsString ( { always : true } )
10
20
@MaxLength ( 500 )
@@ -17,4 +27,82 @@ export class UpdateDatabaseDto extends PartialType(CreateDatabaseDto) {
17
27
@ValidateIf ( ( object , value ) => value !== undefined )
18
28
@IsInt ( { always : true } )
19
29
port : number ;
30
+
31
+ @ApiPropertyOptional ( {
32
+ description : 'Logical database number.' ,
33
+ type : Number ,
34
+ } )
35
+ @IsInt ( )
36
+ @Min ( 0 )
37
+ @IsOptional ( )
38
+ @Default ( null )
39
+ db ?: number ;
40
+
41
+ @ApiPropertyOptional ( {
42
+ description : 'Use TLS to connect.' ,
43
+ type : Boolean ,
44
+ } )
45
+ @IsBoolean ( )
46
+ @IsOptional ( )
47
+ @Default ( false )
48
+ tls ?: boolean ;
49
+
50
+ @ApiPropertyOptional ( {
51
+ description : 'SNI servername' ,
52
+ type : String ,
53
+ } )
54
+ @IsString ( )
55
+ @IsNotEmpty ( )
56
+ @IsOptional ( )
57
+ @Default ( null )
58
+ tlsServername ?: string ;
59
+
60
+ @ApiPropertyOptional ( {
61
+ description : 'The certificate returned by the server needs to be verified.' ,
62
+ type : Boolean ,
63
+ default : false ,
64
+ } )
65
+ @IsOptional ( )
66
+ @IsBoolean ( { always : true } )
67
+ @Default ( false )
68
+ verifyServerCert ?: boolean ;
69
+
70
+ @ApiPropertyOptional ( {
71
+ description : 'CA Certificate' ,
72
+ oneOf : [
73
+ { $ref : getSchemaPath ( CreateCaCertificateDto ) } ,
74
+ { $ref : getSchemaPath ( UseCaCertificateDto ) } ,
75
+ ] ,
76
+ } )
77
+ @IsOptional ( )
78
+ @IsNotEmptyObject ( )
79
+ @Type ( caCertTransformer )
80
+ @ValidateNested ( )
81
+ @Default ( null )
82
+ caCert ?: CreateCaCertificateDto | UseCaCertificateDto ;
83
+
84
+ @ApiPropertyOptional ( {
85
+ description : 'Client Certificate' ,
86
+ oneOf : [
87
+ { $ref : getSchemaPath ( CreateClientCertificateDto ) } ,
88
+ { $ref : getSchemaPath ( UseCaCertificateDto ) } ,
89
+ ] ,
90
+ } )
91
+ @IsOptional ( )
92
+ @IsNotEmptyObject ( )
93
+ @Type ( clientCertTransformer )
94
+ @ValidateNested ( )
95
+ @Default ( null )
96
+ clientCert ?: CreateClientCertificateDto | UseClientCertificateDto ;
97
+
98
+ @ApiPropertyOptional ( {
99
+ description : 'Redis OSS Sentinel master group.' ,
100
+ type : SentinelMaster ,
101
+ } )
102
+ @IsOptional ( )
103
+ @IsNotEmptyObject ( )
104
+ @Type ( ( ) => SentinelMaster )
105
+ @ValidateNested ( )
106
+ @Default ( null )
107
+ sentinelMaster ?: SentinelMaster ;
20
108
}
0 commit comments