validateConnection validates connection parameters including Identity Store fields
(connection *models.QDevConnection)
| 108 | |
| 109 | // validateConnection validates connection parameters including Identity Store fields |
| 110 | func validateConnection(connection *models.QDevConnection) error { |
| 111 | // Validate AWS credentials |
| 112 | if connection.AccessKeyId == "" { |
| 113 | return errors.Default.New("AccessKeyId is required") |
| 114 | } |
| 115 | if connection.SecretAccessKey == "" { |
| 116 | return errors.Default.New("SecretAccessKey is required") |
| 117 | } |
| 118 | if connection.Region == "" { |
| 119 | return errors.Default.New("Region is required") |
| 120 | } |
| 121 | if connection.Bucket == "" { |
| 122 | return errors.Default.New("Bucket is required") |
| 123 | } |
| 124 | |
| 125 | // Identity Store fields are optional, but must be provided together if used |
| 126 | if connection.IdentityStoreId == "" && connection.IdentityStoreRegion != "" { |
| 127 | return errors.Default.New("IdentityStoreRegion provided but IdentityStoreId is empty") |
| 128 | } |
| 129 | if connection.IdentityStoreId != "" && connection.IdentityStoreRegion == "" { |
| 130 | return errors.Default.New("IdentityStoreId provided but IdentityStoreRegion is empty") |
| 131 | } |
| 132 | |
| 133 | // Validate rate limit |
| 134 | if connection.RateLimitPerHour < 0 { |
| 135 | return errors.Default.New("RateLimitPerHour must be positive") |
| 136 | } |
| 137 | if connection.RateLimitPerHour == 0 { |
| 138 | connection.RateLimitPerHour = 20000 // Set default value |
| 139 | } |
| 140 | |
| 141 | return nil |
| 142 | } |