dto.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { ApiProperty } from '@nestjs/swagger';
  2. import { CreateIndexParam } from '@zilliz/milvus2-sdk-node/dist/milvus/types';
  3. import {
  4. IsNotEmpty,
  5. IsString,
  6. IsEnum,
  7. IsOptional,
  8. IsObject,
  9. } from 'class-validator';
  10. class KeyValuePair {
  11. @ApiProperty()
  12. key: string;
  13. @ApiProperty()
  14. value: string;
  15. }
  16. export enum ManageType {
  17. DELETE = 'delete',
  18. CREATE = 'create',
  19. }
  20. export class ManageIndex {
  21. @ApiProperty({ enum: ManageType })
  22. @IsEnum(ManageType, { message: 'Type allow delete and create' })
  23. readonly type: ManageType;
  24. @ApiProperty({
  25. description: 'Milvus collection name',
  26. })
  27. @IsString()
  28. @IsNotEmpty({
  29. message: 'collection_name is empty',
  30. })
  31. readonly collection_name: string;
  32. @ApiProperty({
  33. description: 'field name',
  34. })
  35. @IsString()
  36. @IsNotEmpty({
  37. message: 'field_name is empty',
  38. })
  39. readonly field_name: string;
  40. @ApiProperty({
  41. type: [KeyValuePair],
  42. })
  43. @IsObject()
  44. @IsOptional()
  45. readonly extra_params?: CreateIndexParam;
  46. }
  47. export class DescribeIndex {
  48. @ApiProperty({
  49. description: 'Milvus collection description',
  50. })
  51. @IsString()
  52. @IsNotEmpty({
  53. message: 'collection_name is empty',
  54. })
  55. readonly collection_name: string;
  56. @ApiProperty({
  57. description: 'field name',
  58. })
  59. @IsString()
  60. @IsOptional()
  61. readonly field_name?: string;
  62. }
  63. export class GetIndexState {
  64. @ApiProperty({
  65. description: 'Milvus collection name',
  66. })
  67. @IsString()
  68. @IsNotEmpty({
  69. message: 'collection_name is empty',
  70. })
  71. readonly collection_name: string;
  72. @ApiProperty({
  73. description: 'field name',
  74. })
  75. @IsString()
  76. @IsOptional()
  77. readonly field_name?: string;
  78. }
  79. export class GetIndexProgress {
  80. @ApiProperty({
  81. description: 'Milvus collection name',
  82. })
  83. @IsString()
  84. @IsNotEmpty({
  85. message: 'collection_name is empty',
  86. })
  87. readonly collection_name: string;
  88. @ApiProperty({
  89. description: 'index name',
  90. })
  91. @IsString()
  92. // @IsNotEmpty({
  93. // message: 'index_name is empty',
  94. // })
  95. readonly index_name: string;
  96. @ApiProperty({
  97. description: 'field name',
  98. })
  99. @IsString()
  100. @IsOptional()
  101. readonly field_name?: string;
  102. }