| 1 | from typing import List |
| 2 | from typing import Optional |
| 3 | |
| 4 | from pydantic import BaseModel |
| 5 | from pydantic import ConfigDict |
| 6 | from pydantic import Field |
| 7 | |
| 8 | |
| 9 | class AuthKey(BaseModel): |
| 10 | auth_key_name: str |
| 11 | |
| 12 | |
| 13 | class NetworkConnectorsWithAuthKeys(BaseModel): |
| 14 | id: int |
| 15 | network_connector_name: str |
| 16 | description: str |
| 17 | network_connector_details: str |
| 18 | network_connector_keys: List[AuthKey] |
| 19 | |
| 20 | |
| 21 | class AvailableNetworkConnectorsResponse(BaseModel): |
| 22 | network_connector_keys: List[NetworkConnectorsWithAuthKeys] |
| 23 | message: str |
| 24 | success: bool |
| 25 | |
| 26 | |
| 27 | class CreateNetworkConnectorsService(BaseModel): |
| 28 | auth_type: str = Field( |
| 29 | ..., |
| 30 | description="The authentication type.", |
| 31 | examples=["OAuth"], |
| 32 | ) |
| 33 | config_key: str = Field( |
| 34 | ..., |
| 35 | description="The configuration key.", |
| 36 | examples=["endpoint"], |
| 37 | ) |
| 38 | config_value: str = Field( |
| 39 | ..., |
| 40 | description="The configuration value.", |
| 41 | examples=["https://api.mimecast.com"], |
| 42 | ) |
| 43 | |
| 44 | |
| 45 | class CreateNetworkConnectorsAuthKeys(BaseModel): |
| 46 | auth_key_name: str = Field( |
| 47 | ..., |
| 48 | description="The auth key.", |
| 49 | examples=["username"], |
| 50 | ) |
| 51 | auth_value: str = Field( |
| 52 | ..., |
| 53 | description="The auth value.", |
| 54 | examples=["test-user"], |
| 55 | ) |
| 56 | |
| 57 | |
| 58 | class CustomerNetworkConnectorsCreate(BaseModel): |
| 59 | customer_code: str = Field( |
| 60 | ..., |
| 61 | description="The customer code.", |
| 62 | examples=["00002"], |
| 63 | ) |
| 64 | customer_name: str = Field( |
| 65 | ..., |
| 66 | description="The customer name.", |
| 67 | examples=["SOCFortress"], |
| 68 | ) |
| 69 | network_connector_name: str = Field( |
| 70 | ..., |
| 71 | description="The integration name.", |
| 72 | examples=["Mimecast"], |
| 73 | ) |
| 74 | network_connector_config: CreateNetworkConnectorsService = Field( |
| 75 | ..., |
| 76 | description="The integration service.", |
| 77 | examples=[{"auth_type": "OAuth", "config_key": "endpoint", "config_value": "https://api.mimecast.com"}], |
| 78 | ) |
| 79 | # network_connector_auth_key: CreateIntegrationAuthKeys = Field( |
| 80 | # ..., |
| 81 | # description="The integration metadata.", |
| 82 | # ) |
| 83 | network_connector_auth_keys: List[CreateNetworkConnectorsAuthKeys] = Field( |
| 84 | ..., |
| 85 | description="The integration auth keys.", |
| 86 | ) |
| 87 | |
| 88 | |
| 89 | class CustomerNetworkConnectorsCreateResponse(BaseModel): |
| 90 | message: str = Field( |
| 91 | ..., |
| 92 | description="The message.", |
| 93 | ) |
| 94 | success: bool = Field( |
| 95 | ..., |
| 96 | description="The success status.", |
| 97 | ) |
| 98 | |
| 99 | |
| 100 | class CustomerNetworkConnectorsDeleteResponse(BaseModel): |
| 101 | message: str = Field( |
| 102 | ..., |
| 103 | description="The message.", |
| 104 | ) |
| 105 | success: bool = Field( |
| 106 | ..., |
| 107 | description="The success status.", |
| 108 | ) |
| 109 | |
| 110 | |
| 111 | # class IntegrationConfig(BaseModel): |
| 112 | # config_id: int |
| 113 | # config_value: str |
| 114 | # config_key: str |
| 115 | |
| 116 | # class IntegrationService(BaseModel): |
| 117 | # auth_type: str |
| 118 | # service_name: str |
| 119 | # id: int |
| 120 | |
| 121 | # class IntegrationSubscription(BaseModel): |
| 122 | # id: int |
| 123 | # customer_id: int |
| 124 | # network_connector_service_id: int |
| 125 | # network_connector_service: IntegrationService |
| 126 | # network_connector_config: IntegrationConfig |
| 127 | |
| 128 | # class CustomerNetworkConnectors(BaseModel): |
| 129 | # customer_code: str |
| 130 | # id: int |
| 131 | # customer_name: str |
| 132 | # network_connector_subscriptions: List[IntegrationSubscription] |
| 133 | |
| 134 | # class CustomerNetworkConnectorsResponse(BaseModel): |
| 135 | # available_integrations: List[CustomerNetworkConnectors] |
| 136 | # message: str |
| 137 | # success: bool |
| 138 | |
| 139 | |
| 140 | class NetworkConnectorsAuthKeys(BaseModel): |
| 141 | id: int |
| 142 | auth_key_name: str |
| 143 | auth_value: str |
| 144 | subscription_id: int |
| 145 | |
| 146 | model_config = ConfigDict(from_attributes=True) |
| 147 | |
| 148 | |
| 149 | class NetworkConnectorsService(BaseModel): |
| 150 | auth_type: str |
| 151 | service_name: str |
| 152 | id: int |
| 153 | |
| 154 | model_config = ConfigDict(from_attributes=True) |
| 155 | |
| 156 | |
| 157 | class NetworkConnectorsSubscription(BaseModel): |
| 158 | id: int |
| 159 | customer_id: int |
| 160 | network_connectors_service_id: int |
| 161 | network_connectors_service: NetworkConnectorsService |
| 162 | network_connectors_keys: List[NetworkConnectorsAuthKeys] |
| 163 | |
| 164 | model_config = ConfigDict(from_attributes=True) |
| 165 | |
| 166 | |
| 167 | class CustomerNetworkConnectors(BaseModel): |
| 168 | customer_code: str |
| 169 | id: int |
| 170 | customer_name: str |
| 171 | network_connectors_subscriptions: List[NetworkConnectorsSubscription] |
| 172 | network_connector_service_id: Optional[int] = Field( |
| 173 | None, |
| 174 | description="The integration service id.", |
| 175 | examples=[1], |
| 176 | ) |
| 177 | network_connector_service_name: Optional[str] = Field( |
| 178 | ..., |
| 179 | description="The integration service name.", |
| 180 | examples=["Mimecast"], |
| 181 | ) |
| 182 | deployed: Optional[bool] = Field( |
| 183 | None, |
| 184 | description="The deployment status.", |
| 185 | examples=[True], |
| 186 | ) |
| 187 | |
| 188 | model_config = ConfigDict(from_attributes=True) |
| 189 | |
| 190 | |
| 191 | class CustomerNetworkConnectorsResponse(BaseModel): |
| 192 | available_network_connectors: List[CustomerNetworkConnectors] |
| 193 | message: str |
| 194 | success: bool |
| 195 | |
| 196 | |
| 197 | class DeleteCustomerNetworkConnectors(BaseModel): |
| 198 | customer_code: str = Field( |
| 199 | ..., |
| 200 | description="The customer code.", |
| 201 | examples=["00002"], |
| 202 | ) |
| 203 | network_connector_name: str = Field( |
| 204 | ..., |
| 205 | description="The integration name.", |
| 206 | examples=["Mimecast"], |
| 207 | ) |
| 208 | |
| 209 | |
| 210 | class UpdateCustomerNetworkConnectors(BaseModel): |
| 211 | network_connector_name: str = Field( |
| 212 | ..., |
| 213 | description="The integration name.", |
| 214 | examples=["Mimecast"], |
| 215 | ) |
| 216 | network_connector_auth_keys: List[CreateNetworkConnectorsAuthKeys] = Field( |
| 217 | ..., |
| 218 | description="The integration auth keys.", |
| 219 | ) |
| 220 | |
| 221 | |
| 222 | class CustomerNetworkConnectorsMetaSchema(BaseModel): |
| 223 | id: Optional[int] = None |
| 224 | customer_code: str |
| 225 | network_connector_name: str |
| 226 | graylog_input_id: Optional[str] = None |
| 227 | graylog_index_id: str |
| 228 | graylog_stream_id: str |
| 229 | grafana_org_id: str |
| 230 | grafana_dashboard_folder_id: str |
| 231 | model_config = ConfigDict(from_attributes=True) |
| 232 | |
| 233 | |
| 234 | class CustomerNetworkConnectorsMetaResponse(BaseModel): |
| 235 | message: str |
| 236 | success: bool |
| 237 | customer_network_connectors_meta: Optional[List[CustomerNetworkConnectorsMetaSchema]] = Field( |
| 238 | None, |
| 239 | description="The customer integrations metadata.", |
| 240 | ) |