fastly 17.2.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -1
  3. data/Gemfile.lock +1 -1
  4. data/README.md +73 -2
  5. data/docs/AiRuntimeControlProviderConnectionsApi.md +210 -0
  6. data/docs/AiRuntimeControlProvidersApi.md +121 -0
  7. data/docs/AiRuntimeControlResponseBodyEnable.md +12 -0
  8. data/docs/AiRuntimeControlResponseCustomer.md +10 -0
  9. data/docs/AiRuntimeControlResponseLinks.md +10 -0
  10. data/docs/AiRuntimeControlResponseLinksLinks.md +10 -0
  11. data/docs/AiRuntimeControlResponseProduct.md +10 -0
  12. data/docs/AiRuntimeControlResponseProductProduct.md +11 -0
  13. data/docs/AiRuntimeControlSessionsApi.md +69 -0
  14. data/docs/AiRuntimeControlUsageMetricsApi.md +113 -0
  15. data/docs/AiRuntimeControlVirtualKeysApi.md +334 -0
  16. data/docs/ArcBedrockSetupResponse.md +11 -0
  17. data/docs/ArcCreateVirtualKeyResponse.md +19 -0
  18. data/docs/ArcError.md +12 -0
  19. data/docs/ArcFailoverTarget.md +10 -0
  20. data/docs/ArcGetProviderConnectionResponse.md +19 -0
  21. data/docs/ArcGetProviderConnectionResponseExtra.md +10 -0
  22. data/docs/ArcModel.md +12 -0
  23. data/docs/ArcModelsMeta.md +10 -0
  24. data/docs/ArcModelsResponse.md +11 -0
  25. data/docs/ArcProvider.md +13 -0
  26. data/docs/ArcProviderConnectionApiKey.md +14 -0
  27. data/docs/ArcProviderConnectionAwsIam.md +14 -0
  28. data/docs/ArcProviderConnectionListItemResponse.md +19 -0
  29. data/docs/ArcProviderConnectionListItemResponseExtra.md +10 -0
  30. data/docs/ArcProviderConnectionRequest.md +49 -0
  31. data/docs/ArcProviderConnectionResponse.md +18 -0
  32. data/docs/ArcProviderConnectionsMeta.md +11 -0
  33. data/docs/ArcProviderConnectionsResponse.md +11 -0
  34. data/docs/ArcProvidersMeta.md +10 -0
  35. data/docs/ArcProvidersResponse.md +11 -0
  36. data/docs/ArcRotateVirtualKeyRequest.md +10 -0
  37. data/docs/ArcRotateVirtualKeyResponse.md +17 -0
  38. data/docs/ArcSession.md +28 -0
  39. data/docs/ArcSessionLogEntry.md +12 -0
  40. data/docs/ArcSessionsMeta.md +14 -0
  41. data/docs/ArcSessionsResponse.md +11 -0
  42. data/docs/ArcUpdateProviderConnectionRequest.md +14 -0
  43. data/docs/ArcUpdateVirtualKeyRequest.md +16 -0
  44. data/docs/ArcUpdateVirtualKeyResponse.md +20 -0
  45. data/docs/ArcUsageMetric.md +18 -0
  46. data/docs/ArcUsageMetricsMeta.md +11 -0
  47. data/docs/ArcUsageMetricsResponse.md +11 -0
  48. data/docs/ArcVirtualKey.md +15 -0
  49. data/docs/ArcVirtualKeyFailoverRequest.md +13 -0
  50. data/docs/ArcVirtualKeyFailoverResponse.md +13 -0
  51. data/docs/ArcVirtualKeyListItemResponse.md +26 -0
  52. data/docs/ArcVirtualKeyListItemResponseExtra.md +20 -0
  53. data/docs/ArcVirtualKeyResponse.md +25 -0
  54. data/docs/ArcVirtualKeyResponseExtra.md +19 -0
  55. data/docs/ArcVirtualKeysMeta.md +14 -0
  56. data/docs/ArcVirtualKeysResponse.md +11 -0
  57. data/docs/AutomationToken.md +6 -2
  58. data/docs/AutomationTokenCreateRequest.md +10 -1
  59. data/docs/AutomationTokenCreateResponse.md +6 -2
  60. data/docs/AutomationTokenResponse.md +5 -1
  61. data/docs/AutomationTokenRole.md +11 -0
  62. data/docs/AutomationTokenUnversionedError.md +11 -0
  63. data/docs/AutomationTokenUnversionedErrorResponse.md +10 -0
  64. data/docs/AutomationTokenWorkspace.md +11 -0
  65. data/docs/AutomationTokenWorkspacesMeta.md +12 -0
  66. data/docs/AutomationTokenWorkspacesResponse.md +12 -0
  67. data/docs/AutomationTokensApi.md +43 -1
  68. data/docs/BotManagementAction.md +10 -0
  69. data/docs/BotManagementApi.md +433 -0
  70. data/docs/BotManagementBot.md +10 -0
  71. data/docs/BotManagementBotAction.md +10 -0
  72. data/docs/BotManagementBotResponse.md +12 -0
  73. data/docs/BotManagementBotResponseExtra.md +11 -0
  74. data/docs/BotManagementBotsResponse.md +11 -0
  75. data/docs/BotManagementCategoriesResponse.md +11 -0
  76. data/docs/BotManagementCategory.md +10 -0
  77. data/docs/BotManagementCategoryResponse.md +13 -0
  78. data/docs/BotManagementCategoryResponseExtra.md +12 -0
  79. data/docs/BotManagementError.md +12 -0
  80. data/docs/BotManagementInvalidRequestError.md +12 -0
  81. data/docs/BotManagementInvalidRequestErrorExtra.md +12 -0
  82. data/docs/BotManagementMeta.md +12 -0
  83. data/docs/BotManagementNotAllowedError.md +12 -0
  84. data/docs/BotManagementNotAllowedErrorExtra.md +11 -0
  85. data/docs/BotManagementNotAuthenticatedError.md +12 -0
  86. data/docs/BotManagementNotAuthenticatedErrorExtra.md +11 -0
  87. data/docs/BotManagementNotFoundError.md +12 -0
  88. data/docs/BotManagementNotFoundErrorExtra.md +11 -0
  89. data/docs/BotManagementProtectionMode.md +9 -0
  90. data/docs/BotManagementRateLimitError.md +12 -0
  91. data/docs/BotManagementRateLimitErrorExtra.md +11 -0
  92. data/docs/BotManagementWorkspace.md +12 -0
  93. data/docs/BotManagementWorkspaceBotResponse.md +13 -0
  94. data/docs/BotManagementWorkspaceBotResponseExtra.md +10 -0
  95. data/docs/BotManagementWorkspaceBotsResponse.md +11 -0
  96. data/docs/BotManagementWorkspaceResponse.md +16 -0
  97. data/docs/BotManagementWorkspaceResponseExtra.md +13 -0
  98. data/docs/BotManagementWorkspacesResponse.md +11 -0
  99. data/docs/BotRequestMetricsDataItem.md +16 -0
  100. data/docs/BotRequestMetricsMetadata.md +14 -0
  101. data/docs/BotRequestMetricsResponse.md +11 -0
  102. data/docs/BotRequestsMetricsApi.md +77 -0
  103. data/docs/BulkUpdateDictionaryItem.md +1 -1
  104. data/docs/DdosProtectionRule.md +1 -1
  105. data/docs/DdosProtectionRuleAllOf.md +1 -1
  106. data/docs/DdosProtectionRulePatch.md +1 -1
  107. data/docs/DdosProtectionRuleWithStats.md +1 -1
  108. data/docs/DictionaryItem.md +1 -1
  109. data/docs/DictionaryItemApi.md +14 -14
  110. data/docs/DictionaryItemResponse.md +1 -1
  111. data/docs/MetricsPlatformApi.md +69 -13
  112. data/docs/NetworkProtectApi.md +789 -0
  113. data/docs/NetworkProtectConflict.md +13 -0
  114. data/docs/NetworkProtectConflictError.md +11 -0
  115. data/docs/NetworkProtectEndpoint.md +11 -0
  116. data/docs/NetworkProtectEndpointCreate.md +11 -0
  117. data/docs/NetworkProtectEndpointPolicy.md +11 -0
  118. data/docs/NetworkProtectEndpointResponse.md +14 -0
  119. data/docs/NetworkProtectEndpointResponseFields.md +12 -0
  120. data/docs/NetworkProtectEndpointUpdate.md +10 -0
  121. data/docs/NetworkProtectEndpointsResponse.md +11 -0
  122. data/docs/NetworkProtectErrorDetail.md +11 -0
  123. data/docs/NetworkProtectInvalidRequest.md +13 -0
  124. data/docs/NetworkProtectListMeta.md +11 -0
  125. data/docs/NetworkProtectLoaStatus.md +9 -0
  126. data/docs/NetworkProtectNetwork.md +15 -0
  127. data/docs/NetworkProtectNetworkCreate.md +14 -0
  128. data/docs/NetworkProtectNetworkResponse.md +22 -0
  129. data/docs/NetworkProtectNetworkResponseFields.md +16 -0
  130. data/docs/NetworkProtectNetworkUpdate.md +14 -0
  131. data/docs/NetworkProtectNetworksResponse.md +11 -0
  132. data/docs/NetworkProtectPolicyEndpoint.md +13 -0
  133. data/docs/NetworkProtectPrefixList.md +12 -0
  134. data/docs/NetworkProtectPrefixListCreate.md +12 -0
  135. data/docs/NetworkProtectPrefixListFamily.md +9 -0
  136. data/docs/NetworkProtectPrefixListResponse.md +15 -0
  137. data/docs/NetworkProtectPrefixListResponseFields.md +12 -0
  138. data/docs/NetworkProtectPrefixListUpdate.md +11 -0
  139. data/docs/NetworkProtectPrefixListsResponse.md +11 -0
  140. data/docs/NetworkProtectRegion.md +9 -0
  141. data/docs/NetworkProtectRoaStatus.md +9 -0
  142. data/docs/NetworkProtectRule.md +16 -0
  143. data/docs/NetworkProtectRuleAction.md +9 -0
  144. data/docs/NetworkProtectRuleDestinationPorts.md +9 -0
  145. data/docs/NetworkProtectRuleIpProtocol.md +9 -0
  146. data/docs/NetworkProtectRuleMatchDestinationIp.md +10 -0
  147. data/docs/NetworkProtectRuleMatchDestinationPorts.md +10 -0
  148. data/docs/NetworkProtectRuleMatchIpProtocol.md +10 -0
  149. data/docs/NetworkProtectRuleMatchSourcePorts.md +10 -0
  150. data/docs/NetworkProtectRuleMatchSourcePrefixList.md +10 -0
  151. data/docs/NetworkProtectRuleResponse.md +16 -0
  152. data/docs/NetworkProtectRuleSet.md +11 -0
  153. data/docs/NetworkProtectRuleSetCreate.md +11 -0
  154. data/docs/NetworkProtectRuleSetDefaultAction.md +9 -0
  155. data/docs/NetworkProtectRuleSetResponse.md +14 -0
  156. data/docs/NetworkProtectRuleSetResponseFields.md +12 -0
  157. data/docs/NetworkProtectRuleSetUpdate.md +11 -0
  158. data/docs/NetworkProtectRuleSetsResponse.md +11 -0
  159. data/docs/NetworkProtectRuleSourcePorts.md +9 -0
  160. data/docs/NetworkProtectRuleTimestamps.md +11 -0
  161. data/docs/PlatformValues.md +359 -16
  162. data/docs/ProductAiRuntimeControlApi.md +115 -0
  163. data/docs/PurgeApi.md +6 -0
  164. data/docs/RealtimeEntryAggregated.md +16 -0
  165. data/docs/RealtimeEntryDatacenter.md +16 -0
  166. data/docs/RealtimeMeasurements.md +16 -0
  167. data/docs/Results.md +16 -0
  168. data/lib/fastly/api/ai_runtime_control_provider_connections_api.rb +355 -0
  169. data/lib/fastly/api/ai_runtime_control_providers_api.rb +195 -0
  170. data/lib/fastly/api/ai_runtime_control_sessions_api.rb +112 -0
  171. data/lib/fastly/api/ai_runtime_control_usage_metrics_api.rb +176 -0
  172. data/lib/fastly/api/ai_runtime_control_virtual_keys_api.rb +580 -0
  173. data/lib/fastly/api/automation_tokens_api.rb +78 -1
  174. data/lib/fastly/api/bot_management_api.rb +787 -0
  175. data/lib/fastly/api/bot_requests_metrics_api.rb +137 -0
  176. data/lib/fastly/api/dictionary_item_api.rb +14 -14
  177. data/lib/fastly/api/metrics_platform_api.rb +130 -23
  178. data/lib/fastly/api/network_protect_api.rb +1420 -0
  179. data/lib/fastly/api/product_ai_runtime_control_api.rb +186 -0
  180. data/lib/fastly/api/purge_api.rb +21 -0
  181. data/lib/fastly/configuration.rb +331 -1
  182. data/lib/fastly/models/ai_runtime_control_response_body_enable.rb +243 -0
  183. data/lib/fastly/models/ai_runtime_control_response_customer.rb +216 -0
  184. data/lib/fastly/models/ai_runtime_control_response_links.rb +216 -0
  185. data/lib/fastly/models/ai_runtime_control_response_links_links.rb +217 -0
  186. data/lib/fastly/models/ai_runtime_control_response_product.rb +216 -0
  187. data/lib/fastly/models/ai_runtime_control_response_product_product.rb +227 -0
  188. data/lib/fastly/models/arc_bedrock_setup_response.rb +237 -0
  189. data/lib/fastly/models/arc_create_virtual_key_response.rb +346 -0
  190. data/lib/fastly/models/arc_error.rb +238 -0
  191. data/lib/fastly/models/arc_failover_target.rb +223 -0
  192. data/lib/fastly/models/arc_get_provider_connection_response.rb +393 -0
  193. data/lib/fastly/models/arc_get_provider_connection_response_extra.rb +224 -0
  194. data/lib/fastly/models/arc_model.rb +253 -0
  195. data/lib/fastly/models/arc_models_meta.rb +217 -0
  196. data/lib/fastly/models/arc_models_response.rb +238 -0
  197. data/lib/fastly/models/arc_provider.rb +270 -0
  198. data/lib/fastly/models/arc_provider_connection_api_key.rb +335 -0
  199. data/lib/fastly/models/arc_provider_connection_aws_iam.rb +350 -0
  200. data/lib/fastly/models/arc_provider_connection_list_item_response.rb +386 -0
  201. data/lib/fastly/models/arc_provider_connection_list_item_response_extra.rb +217 -0
  202. data/lib/fastly/models/arc_provider_connection_request.rb +103 -0
  203. data/lib/fastly/models/arc_provider_connection_response.rb +369 -0
  204. data/lib/fastly/models/arc_provider_connections_meta.rb +228 -0
  205. data/lib/fastly/models/arc_provider_connections_response.rb +238 -0
  206. data/lib/fastly/models/arc_providers_meta.rb +217 -0
  207. data/lib/fastly/models/arc_providers_response.rb +238 -0
  208. data/lib/fastly/models/arc_rotate_virtual_key_request.rb +218 -0
  209. data/lib/fastly/models/arc_rotate_virtual_key_response.rb +324 -0
  210. data/lib/fastly/models/arc_session.rb +465 -0
  211. data/lib/fastly/models/arc_session_log_entry.rb +240 -0
  212. data/lib/fastly/models/arc_sessions_meta.rb +260 -0
  213. data/lib/fastly/models/arc_sessions_response.rb +238 -0
  214. data/lib/fastly/models/arc_update_provider_connection_request.rb +275 -0
  215. data/lib/fastly/models/arc_update_virtual_key_request.rb +345 -0
  216. data/lib/fastly/models/arc_update_virtual_key_response.rb +352 -0
  217. data/lib/fastly/models/arc_usage_metric.rb +347 -0
  218. data/lib/fastly/models/arc_usage_metrics_meta.rb +228 -0
  219. data/lib/fastly/models/arc_usage_metrics_response.rb +238 -0
  220. data/lib/fastly/models/arc_virtual_key.rb +342 -0
  221. data/lib/fastly/models/arc_virtual_key_failover_request.rb +255 -0
  222. data/lib/fastly/models/arc_virtual_key_failover_response.rb +270 -0
  223. data/lib/fastly/models/arc_virtual_key_list_item_response.rb +492 -0
  224. data/lib/fastly/models/arc_virtual_key_list_item_response_extra.rb +350 -0
  225. data/lib/fastly/models/arc_virtual_key_response.rb +477 -0
  226. data/lib/fastly/models/arc_virtual_key_response_extra.rb +335 -0
  227. data/lib/fastly/models/arc_virtual_keys_meta.rb +260 -0
  228. data/lib/fastly/models/arc_virtual_keys_response.rb +238 -0
  229. data/lib/fastly/models/automation_token.rb +49 -5
  230. data/lib/fastly/models/automation_token_create_request.rb +161 -7
  231. data/lib/fastly/models/automation_token_create_response.rb +49 -5
  232. data/lib/fastly/models/automation_token_error_response.rb +1 -0
  233. data/lib/fastly/models/automation_token_response.rb +46 -2
  234. data/lib/fastly/models/automation_token_role.rb +227 -0
  235. data/lib/fastly/models/automation_token_unversioned_error.rb +225 -0
  236. data/lib/fastly/models/automation_token_unversioned_error_response.rb +219 -0
  237. data/lib/fastly/models/automation_token_workspace.rb +237 -0
  238. data/lib/fastly/models/automation_token_workspaces_meta.rb +242 -0
  239. data/lib/fastly/models/automation_token_workspaces_response.rb +253 -0
  240. data/lib/fastly/models/bot_management_action.rb +257 -0
  241. data/lib/fastly/models/bot_management_bot.rb +222 -0
  242. data/lib/fastly/models/bot_management_bot_action.rb +257 -0
  243. data/lib/fastly/models/bot_management_bot_response.rb +259 -0
  244. data/lib/fastly/models/bot_management_bot_response_extra.rb +237 -0
  245. data/lib/fastly/models/bot_management_bots_response.rb +238 -0
  246. data/lib/fastly/models/bot_management_categories_response.rb +238 -0
  247. data/lib/fastly/models/bot_management_category.rb +222 -0
  248. data/lib/fastly/models/bot_management_category_response.rb +269 -0
  249. data/lib/fastly/models/bot_management_category_response_extra.rb +247 -0
  250. data/lib/fastly/models/bot_management_error.rb +248 -0
  251. data/lib/fastly/models/bot_management_invalid_request_error.rb +291 -0
  252. data/lib/fastly/models/bot_management_invalid_request_error_extra.rb +283 -0
  253. data/lib/fastly/models/bot_management_meta.rb +239 -0
  254. data/lib/fastly/models/bot_management_not_allowed_error.rb +287 -0
  255. data/lib/fastly/models/bot_management_not_allowed_error_extra.rb +259 -0
  256. data/lib/fastly/models/bot_management_not_authenticated_error.rb +287 -0
  257. data/lib/fastly/models/bot_management_not_authenticated_error_extra.rb +259 -0
  258. data/lib/fastly/models/bot_management_not_found_error.rb +287 -0
  259. data/lib/fastly/models/bot_management_not_found_error_extra.rb +259 -0
  260. data/lib/fastly/models/bot_management_protection_mode.rb +36 -0
  261. data/lib/fastly/models/bot_management_rate_limit_error.rb +287 -0
  262. data/lib/fastly/models/bot_management_rate_limit_error_extra.rb +259 -0
  263. data/lib/fastly/models/bot_management_workspace.rb +276 -0
  264. data/lib/fastly/models/bot_management_workspace_bot_response.rb +275 -0
  265. data/lib/fastly/models/bot_management_workspace_bot_response_extra.rb +222 -0
  266. data/lib/fastly/models/bot_management_workspace_bots_response.rb +238 -0
  267. data/lib/fastly/models/bot_management_workspace_response.rb +354 -0
  268. data/lib/fastly/models/bot_management_workspace_response_extra.rb +264 -0
  269. data/lib/fastly/models/bot_management_workspaces_response.rb +238 -0
  270. data/lib/fastly/models/bot_request_metrics_data_item.rb +278 -0
  271. data/lib/fastly/models/bot_request_metrics_metadata.rb +258 -0
  272. data/lib/fastly/models/bot_request_metrics_response.rb +228 -0
  273. data/lib/fastly/models/bulk_update_dictionary_item.rb +1 -1
  274. data/lib/fastly/models/ddos_protection_request_enable_mode.rb +2 -2
  275. data/lib/fastly/models/ddos_protection_request_update_configuration.rb +2 -2
  276. data/lib/fastly/models/ddos_protection_rule.rb +1 -1
  277. data/lib/fastly/models/ddos_protection_rule_all_of.rb +1 -1
  278. data/lib/fastly/models/ddos_protection_rule_patch.rb +1 -1
  279. data/lib/fastly/models/ddos_protection_rule_with_stats.rb +1 -1
  280. data/lib/fastly/models/dictionary_item.rb +1 -1
  281. data/lib/fastly/models/dictionary_item_response.rb +1 -1
  282. data/lib/fastly/models/event_attributes.rb +2 -2
  283. data/lib/fastly/models/network_protect_conflict.rb +299 -0
  284. data/lib/fastly/models/network_protect_conflict_error.rb +228 -0
  285. data/lib/fastly/models/network_protect_endpoint.rb +266 -0
  286. data/lib/fastly/models/network_protect_endpoint_create.rb +266 -0
  287. data/lib/fastly/models/network_protect_endpoint_policy.rb +255 -0
  288. data/lib/fastly/models/network_protect_endpoint_response.rb +340 -0
  289. data/lib/fastly/models/network_protect_endpoint_response_fields.rb +274 -0
  290. data/lib/fastly/models/network_protect_endpoint_update.rb +251 -0
  291. data/lib/fastly/models/network_protect_endpoints_response.rb +239 -0
  292. data/lib/fastly/models/network_protect_error_detail.rb +238 -0
  293. data/lib/fastly/models/{automation_token_create_request_attributes.rb → network_protect_invalid_request.rb} +63 -75
  294. data/lib/fastly/models/network_protect_list_meta.rb +263 -0
  295. data/lib/fastly/models/network_protect_loa_status.rb +36 -0
  296. data/lib/fastly/models/network_protect_network.rb +363 -0
  297. data/lib/fastly/models/network_protect_network_create.rb +340 -0
  298. data/lib/fastly/models/network_protect_network_response.rb +477 -0
  299. data/lib/fastly/models/network_protect_network_response_fields.rb +314 -0
  300. data/lib/fastly/models/network_protect_network_update.rb +329 -0
  301. data/lib/fastly/models/network_protect_networks_response.rb +239 -0
  302. data/lib/fastly/models/network_protect_policy_endpoint.rb +307 -0
  303. data/lib/fastly/models/network_protect_prefix_list.rb +282 -0
  304. data/lib/fastly/models/network_protect_prefix_list_create.rb +301 -0
  305. data/lib/fastly/models/network_protect_prefix_list_family.rb +35 -0
  306. data/lib/fastly/models/network_protect_prefix_list_response.rb +356 -0
  307. data/lib/fastly/models/network_protect_prefix_list_response_fields.rb +274 -0
  308. data/lib/fastly/models/network_protect_prefix_list_update.rb +269 -0
  309. data/lib/fastly/models/network_protect_prefix_lists_response.rb +239 -0
  310. data/lib/fastly/models/network_protect_region.rb +34 -0
  311. data/lib/fastly/models/network_protect_roa_status.rb +37 -0
  312. data/lib/fastly/models/network_protect_rule.rb +372 -0
  313. data/lib/fastly/models/network_protect_rule_action.rb +35 -0
  314. data/lib/fastly/models/network_protect_rule_destination_ports.rb +208 -0
  315. data/lib/fastly/models/network_protect_rule_ip_protocol.rb +37 -0
  316. data/lib/fastly/models/network_protect_rule_match_destination_ip.rb +223 -0
  317. data/lib/fastly/models/network_protect_rule_match_destination_ports.rb +222 -0
  318. data/lib/fastly/models/network_protect_rule_match_ip_protocol.rb +222 -0
  319. data/lib/fastly/models/network_protect_rule_match_source_ports.rb +222 -0
  320. data/lib/fastly/models/network_protect_rule_match_source_prefix_list.rb +244 -0
  321. data/lib/fastly/models/network_protect_rule_response.rb +329 -0
  322. data/lib/fastly/models/network_protect_rule_set.rb +258 -0
  323. data/lib/fastly/models/network_protect_rule_set_create.rb +249 -0
  324. data/lib/fastly/models/network_protect_rule_set_default_action.rb +35 -0
  325. data/lib/fastly/models/network_protect_rule_set_response.rb +332 -0
  326. data/lib/fastly/models/network_protect_rule_set_response_fields.rb +274 -0
  327. data/lib/fastly/models/network_protect_rule_set_update.rb +244 -0
  328. data/lib/fastly/models/network_protect_rule_sets_response.rb +239 -0
  329. data/lib/fastly/models/network_protect_rule_source_ports.rb +208 -0
  330. data/lib/fastly/models/network_protect_rule_timestamps.rb +228 -0
  331. data/lib/fastly/models/platform_values.rb +3568 -137
  332. data/lib/fastly/models/realtime_entry_aggregated.rb +164 -4
  333. data/lib/fastly/models/realtime_entry_datacenter.rb +164 -4
  334. data/lib/fastly/models/realtime_measurements.rb +164 -4
  335. data/lib/fastly/models/results.rb +161 -1
  336. data/lib/fastly/version.rb +1 -1
  337. data/lib/fastly.rb +143 -1
  338. data/sig.json +1 -1
  339. metadata +288 -4
  340. data/docs/AutomationTokenCreateRequestAttributes.md +0 -15
@@ -0,0 +1,386 @@
1
+ =begin
2
+ #Fastly API
3
+
4
+ #Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: oss@fastly.com
8
+
9
+ =end
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module Fastly
15
+ class ArcProviderConnectionListItemResponse
16
+ # The unique identifier of the provider connection.
17
+ attr_accessor :id
18
+
19
+ # An opaque identifier for the secret material backing this connection. Not the secret itself.
20
+ attr_accessor :secret_id
21
+
22
+ # The display name of the provider connection.
23
+ attr_accessor :name
24
+
25
+ # The AI model identifiers this connection is allowed to use.
26
+ attr_accessor :models
27
+
28
+ # The authentication type for this connection.
29
+ attr_accessor :auth_type
30
+
31
+ # The date and time the connection was created, in RFC 3339 format.
32
+ attr_accessor :created_at
33
+
34
+ # The date and time the connection was last updated, in RFC 3339 format.
35
+ attr_accessor :updated_at
36
+
37
+ # The base URL of the provider's API. Present only for `api-key` connections.
38
+ attr_accessor :base_url
39
+
40
+ # The AWS region for Bedrock API requests. Present only for `aws-iam` connections.
41
+ attr_accessor :region
42
+
43
+ # The date and time the connection was deleted, in RFC 3339 format. Present only for deleted connections, which are returned only when `include_deleted` is `true`.
44
+ attr_accessor :deleted_at
45
+
46
+ class EnumAttributeValidator
47
+ attr_reader :datatype
48
+ attr_reader :allowable_values
49
+
50
+ def initialize(datatype, allowable_values)
51
+ @allowable_values = allowable_values.map do |value|
52
+ case datatype.to_s
53
+ when /Integer/i
54
+ value.to_i
55
+ when /Float/i
56
+ value.to_f
57
+ else
58
+ value
59
+ end
60
+ end
61
+ end
62
+
63
+ def valid?(value)
64
+ !value || allowable_values.include?(value)
65
+ end
66
+ end
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'id' => :'id',
72
+ :'secret_id' => :'secret_id',
73
+ :'name' => :'name',
74
+ :'models' => :'models',
75
+ :'auth_type' => :'auth_type',
76
+ :'created_at' => :'created_at',
77
+ :'updated_at' => :'updated_at',
78
+ :'base_url' => :'base_url',
79
+ :'region' => :'region',
80
+ :'deleted_at' => :'deleted_at'
81
+ }
82
+ end
83
+
84
+ # Returns all the JSON keys this model knows about
85
+ def self.acceptable_attributes
86
+ attribute_map.values
87
+ end
88
+
89
+ # Attribute type mapping.
90
+ def self.fastly_types
91
+ {
92
+ :'id' => :'String',
93
+ :'secret_id' => :'String',
94
+ :'name' => :'String',
95
+ :'models' => :'Array<String>',
96
+ :'auth_type' => :'String',
97
+ :'created_at' => :'Time',
98
+ :'updated_at' => :'Time',
99
+ :'base_url' => :'String',
100
+ :'region' => :'String',
101
+ :'deleted_at' => :'Time'
102
+ }
103
+ end
104
+
105
+ # List of attributes with nullable: true
106
+ def self.fastly_nullable
107
+ Set.new([
108
+ ])
109
+ end
110
+
111
+ # List of class defined in allOf (OpenAPI v3)
112
+ def self.fastly_all_of
113
+ [
114
+ :'ArcProviderConnectionListItemResponseExtra',
115
+ :'ArcProviderConnectionResponse'
116
+ ]
117
+ end
118
+
119
+ # Initializes the object
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ def initialize(attributes = {})
122
+ if (!attributes.is_a?(Hash))
123
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::ArcProviderConnectionListItemResponse` initialize method"
124
+ end
125
+
126
+ # check to see if the attribute exists and convert string to symbol for hash key
127
+ attributes = attributes.each_with_object({}) { |(k, v), h|
128
+ if (!self.class.attribute_map.key?(k.to_sym))
129
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::ArcProviderConnectionListItemResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
130
+ end
131
+ h[k.to_sym] = v
132
+ }
133
+
134
+ if attributes.key?(:'id')
135
+ self.id = attributes[:'id']
136
+ end
137
+
138
+ if attributes.key?(:'secret_id')
139
+ self.secret_id = attributes[:'secret_id']
140
+ end
141
+
142
+ if attributes.key?(:'name')
143
+ self.name = attributes[:'name']
144
+ end
145
+
146
+ if attributes.key?(:'models')
147
+ if (value = attributes[:'models']).is_a?(Array)
148
+ self.models = value
149
+ end
150
+ end
151
+
152
+ if attributes.key?(:'auth_type')
153
+ self.auth_type = attributes[:'auth_type']
154
+ end
155
+
156
+ if attributes.key?(:'created_at')
157
+ self.created_at = attributes[:'created_at']
158
+ end
159
+
160
+ if attributes.key?(:'updated_at')
161
+ self.updated_at = attributes[:'updated_at']
162
+ end
163
+
164
+ if attributes.key?(:'base_url')
165
+ self.base_url = attributes[:'base_url']
166
+ end
167
+
168
+ if attributes.key?(:'region')
169
+ self.region = attributes[:'region']
170
+ end
171
+
172
+ if attributes.key?(:'deleted_at')
173
+ self.deleted_at = attributes[:'deleted_at']
174
+ end
175
+ end
176
+
177
+ # Show invalid properties with the reasons. Usually used together with valid?
178
+ # @return Array for valid properties with the reasons
179
+ def list_invalid_properties
180
+ invalid_properties = Array.new
181
+ if @id.nil?
182
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
183
+ end
184
+
185
+ if @secret_id.nil?
186
+ invalid_properties.push('invalid value for "secret_id", secret_id cannot be nil.')
187
+ end
188
+
189
+ if @name.nil?
190
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
191
+ end
192
+
193
+ if @models.nil?
194
+ invalid_properties.push('invalid value for "models", models cannot be nil.')
195
+ end
196
+
197
+ if @auth_type.nil?
198
+ invalid_properties.push('invalid value for "auth_type", auth_type cannot be nil.')
199
+ end
200
+
201
+ if @created_at.nil?
202
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
203
+ end
204
+
205
+ if @updated_at.nil?
206
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
207
+ end
208
+
209
+ invalid_properties
210
+ end
211
+
212
+ # Check to see if the all the properties in the model are valid
213
+ # @return true if the model is valid
214
+ def valid?
215
+ return false if @id.nil?
216
+ return false if @secret_id.nil?
217
+ return false if @name.nil?
218
+ return false if @models.nil?
219
+ return false if @auth_type.nil?
220
+ auth_type_validator = EnumAttributeValidator.new('String', ["api-key", "aws-iam"])
221
+ return false unless auth_type_validator.valid?(@auth_type)
222
+ return false if @created_at.nil?
223
+ return false if @updated_at.nil?
224
+ true
225
+ end
226
+
227
+ # Custom attribute writer method checking allowed values (enum).
228
+ # @param [Object] auth_type Object to be assigned
229
+ def auth_type=(auth_type)
230
+ validator = EnumAttributeValidator.new('String', ["api-key", "aws-iam"])
231
+ unless validator.valid?(auth_type)
232
+ fail ArgumentError, "invalid value for \"auth_type\", must be one of #{validator.allowable_values}."
233
+ end
234
+ @auth_type = auth_type
235
+ end
236
+
237
+ # Checks equality by comparing each attribute.
238
+ # @param [Object] Object to be compared
239
+ def ==(o)
240
+ return true if self.equal?(o)
241
+ self.class == o.class &&
242
+ id == o.id &&
243
+ secret_id == o.secret_id &&
244
+ name == o.name &&
245
+ models == o.models &&
246
+ auth_type == o.auth_type &&
247
+ created_at == o.created_at &&
248
+ updated_at == o.updated_at &&
249
+ base_url == o.base_url &&
250
+ region == o.region &&
251
+ deleted_at == o.deleted_at
252
+ end
253
+
254
+ # @see the `==` method
255
+ # @param [Object] Object to be compared
256
+ def eql?(o)
257
+ self == o
258
+ end
259
+
260
+ # Calculates hash code according to all attributes.
261
+ # @return [Integer] Hash code
262
+ def hash
263
+ [id, secret_id, name, models, auth_type, created_at, updated_at, base_url, region, deleted_at].hash
264
+ end
265
+
266
+ # Builds the object from hash
267
+ # @param [Hash] attributes Model attributes in the form of hash
268
+ # @return [Object] Returns the model itself
269
+ def self.build_from_hash(attributes)
270
+ new.build_from_hash(attributes)
271
+ end
272
+
273
+ # Builds the object from hash
274
+ # @param [Hash] attributes Model attributes in the form of hash
275
+ # @return [Object] Returns the model itself
276
+ def build_from_hash(attributes)
277
+ return nil unless attributes.is_a?(Hash)
278
+ self.class.fastly_types.each_pair do |key, type|
279
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
280
+ self.send("#{key}=", nil)
281
+ elsif type =~ /\AArray<(.*)>/i
282
+ # check to ensure the input is an array given that the attribute
283
+ # is documented as an array but the input is not
284
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
285
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
286
+ end
287
+ elsif !attributes[self.class.attribute_map[key]].nil?
288
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
289
+ end
290
+ end
291
+
292
+ self
293
+ end
294
+
295
+ # Deserializes the data based on type
296
+ # @param string type Data type
297
+ # @param string value Value to be deserialized
298
+ # @return [Object] Deserialized data
299
+ def _deserialize(type, value)
300
+ case type.to_sym
301
+ when :Time
302
+ Time.parse(value)
303
+ when :Date
304
+ Date.parse(value)
305
+ when :String
306
+ value.to_s
307
+ when :Integer
308
+ value.to_i
309
+ when :Float
310
+ value.to_f
311
+ when :Boolean
312
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
313
+ true
314
+ else
315
+ false
316
+ end
317
+ when :Object
318
+ # generic object (usually a Hash), return directly
319
+ value
320
+ when /\AArray<(?<inner_type>.+)>\z/
321
+ inner_type = Regexp.last_match[:inner_type]
322
+ value.map { |v| _deserialize(inner_type, v) }
323
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
324
+ k_type = Regexp.last_match[:k_type]
325
+ v_type = Regexp.last_match[:v_type]
326
+ {}.tap do |hash|
327
+ value.each do |k, v|
328
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
329
+ end
330
+ end
331
+ else # model
332
+ # models (e.g. Pet) or oneOf
333
+ klass = Fastly.const_get(type)
334
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
335
+ end
336
+ end
337
+
338
+ # Returns the string representation of the object
339
+ # @return [String] String presentation of the object
340
+ def to_s
341
+ to_hash.to_s
342
+ end
343
+
344
+ # to_body is an alias to to_hash (backward compatibility)
345
+ # @return [Hash] Returns the object in the form of hash
346
+ def to_body
347
+ to_hash
348
+ end
349
+
350
+ # Returns the object in the form of hash
351
+ # @return [Hash] Returns the object in the form of hash
352
+ def to_hash
353
+ hash = {}
354
+ self.class.attribute_map.each_pair do |attr, param|
355
+ value = self.send(attr)
356
+ if value.nil?
357
+ is_nullable = self.class.fastly_nullable.include?(attr)
358
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
359
+ end
360
+
361
+ hash[param] = _to_hash(value)
362
+ end
363
+ hash
364
+ end
365
+
366
+ # Outputs non-array value in the form of hash
367
+ # For object, use to_hash. Otherwise, just return the value
368
+ # @param [Object] value Any valid value
369
+ # @return [Hash] Returns the value in the form of hash
370
+ def _to_hash(value)
371
+ if value.is_a?(Array)
372
+ value.compact.map { |v| _to_hash(v) }
373
+ elsif value.is_a?(Hash)
374
+ {}.tap do |hash|
375
+ value.each { |k, v| hash[k] = _to_hash(v) }
376
+ end
377
+ elsif value.respond_to? :to_hash
378
+ value.to_hash
379
+ else
380
+ value
381
+ end
382
+ end
383
+
384
+ end
385
+
386
+ end
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #Fastly API
3
+
4
+ #Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: oss@fastly.com
8
+
9
+ =end
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module Fastly
15
+ class ArcProviderConnectionListItemResponseExtra
16
+ # The date and time the connection was deleted, in RFC 3339 format. Present only for deleted connections, which are returned only when `include_deleted` is `true`.
17
+ attr_accessor :deleted_at
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'deleted_at' => :'deleted_at'
23
+ }
24
+ end
25
+
26
+ # Returns all the JSON keys this model knows about
27
+ def self.acceptable_attributes
28
+ attribute_map.values
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.fastly_types
33
+ {
34
+ :'deleted_at' => :'Time'
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.fastly_nullable
40
+ Set.new([
41
+ ])
42
+ end
43
+
44
+ # Initializes the object
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ def initialize(attributes = {})
47
+ if (!attributes.is_a?(Hash))
48
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::ArcProviderConnectionListItemResponseExtra` initialize method"
49
+ end
50
+
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::ArcProviderConnectionListItemResponseExtra`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ end
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:'deleted_at')
60
+ self.deleted_at = attributes[:'deleted_at']
61
+ end
62
+ end
63
+
64
+ # Show invalid properties with the reasons. Usually used together with valid?
65
+ # @return Array for valid properties with the reasons
66
+ def list_invalid_properties
67
+ invalid_properties = Array.new
68
+ invalid_properties
69
+ end
70
+
71
+ # Check to see if the all the properties in the model are valid
72
+ # @return true if the model is valid
73
+ def valid?
74
+ true
75
+ end
76
+
77
+ # Checks equality by comparing each attribute.
78
+ # @param [Object] Object to be compared
79
+ def ==(o)
80
+ return true if self.equal?(o)
81
+ self.class == o.class &&
82
+ deleted_at == o.deleted_at
83
+ end
84
+
85
+ # @see the `==` method
86
+ # @param [Object] Object to be compared
87
+ def eql?(o)
88
+ self == o
89
+ end
90
+
91
+ # Calculates hash code according to all attributes.
92
+ # @return [Integer] Hash code
93
+ def hash
94
+ [deleted_at].hash
95
+ end
96
+
97
+ # Builds the object from hash
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ # @return [Object] Returns the model itself
100
+ def self.build_from_hash(attributes)
101
+ new.build_from_hash(attributes)
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def build_from_hash(attributes)
108
+ return nil unless attributes.is_a?(Hash)
109
+ self.class.fastly_types.each_pair do |key, type|
110
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
111
+ self.send("#{key}=", nil)
112
+ elsif type =~ /\AArray<(.*)>/i
113
+ # check to ensure the input is an array given that the attribute
114
+ # is documented as an array but the input is not
115
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
116
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
117
+ end
118
+ elsif !attributes[self.class.attribute_map[key]].nil?
119
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
+ end
121
+ end
122
+
123
+ self
124
+ end
125
+
126
+ # Deserializes the data based on type
127
+ # @param string type Data type
128
+ # @param string value Value to be deserialized
129
+ # @return [Object] Deserialized data
130
+ def _deserialize(type, value)
131
+ case type.to_sym
132
+ when :Time
133
+ Time.parse(value)
134
+ when :Date
135
+ Date.parse(value)
136
+ when :String
137
+ value.to_s
138
+ when :Integer
139
+ value.to_i
140
+ when :Float
141
+ value.to_f
142
+ when :Boolean
143
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
144
+ true
145
+ else
146
+ false
147
+ end
148
+ when :Object
149
+ # generic object (usually a Hash), return directly
150
+ value
151
+ when /\AArray<(?<inner_type>.+)>\z/
152
+ inner_type = Regexp.last_match[:inner_type]
153
+ value.map { |v| _deserialize(inner_type, v) }
154
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
155
+ k_type = Regexp.last_match[:k_type]
156
+ v_type = Regexp.last_match[:v_type]
157
+ {}.tap do |hash|
158
+ value.each do |k, v|
159
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
160
+ end
161
+ end
162
+ else # model
163
+ # models (e.g. Pet) or oneOf
164
+ klass = Fastly.const_get(type)
165
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
166
+ end
167
+ end
168
+
169
+ # Returns the string representation of the object
170
+ # @return [String] String presentation of the object
171
+ def to_s
172
+ to_hash.to_s
173
+ end
174
+
175
+ # to_body is an alias to to_hash (backward compatibility)
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_body
178
+ to_hash
179
+ end
180
+
181
+ # Returns the object in the form of hash
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_hash
184
+ hash = {}
185
+ self.class.attribute_map.each_pair do |attr, param|
186
+ value = self.send(attr)
187
+ if value.nil?
188
+ is_nullable = self.class.fastly_nullable.include?(attr)
189
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
190
+ end
191
+
192
+ hash[param] = _to_hash(value)
193
+ end
194
+ hash
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map { |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to? :to_hash
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+
215
+ end
216
+
217
+ end
@@ -0,0 +1,103 @@
1
+ =begin
2
+ #Fastly API
3
+
4
+ #Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: oss@fastly.com
8
+
9
+ =end
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module Fastly
15
+ module ArcProviderConnectionRequest
16
+ class << self
17
+ # List of class defined in oneOf (OpenAPI v3)
18
+ def fastly_one_of
19
+ [
20
+ :'ArcProviderConnectionApiKey',
21
+ :'ArcProviderConnectionAwsIam'
22
+ ]
23
+ end
24
+
25
+ # Builds the object
26
+ # @param [Mixed] Data to be matched against the list of oneOf items
27
+ # @return [Object] Returns the model or the data itself
28
+ def build(data)
29
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
30
+ # Note:
31
+ # - We do not attempt to check whether exactly one item matches.
32
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
33
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
34
+ # - TODO: scalar values are de facto behaving as if they were nullable.
35
+ # - TODO: logging when debugging is set.
36
+ fastly_one_of.each do |klass|
37
+ begin
38
+ next if klass == :AnyType # "nullable: true"
39
+ typed_data = find_and_cast_into_type(klass, data)
40
+ return typed_data if typed_data
41
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
42
+ end
43
+ end
44
+
45
+ fastly_one_of.include?(:AnyType) ? data : nil
46
+ end
47
+
48
+ private
49
+
50
+ SchemaMismatchError = Class.new(StandardError)
51
+
52
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
53
+ def find_and_cast_into_type(klass, data)
54
+ return if data.nil?
55
+
56
+ case klass.to_s
57
+ when 'Boolean'
58
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
59
+ when 'Float'
60
+ return data if data.instance_of?(Float)
61
+ when 'Integer'
62
+ return data if data.instance_of?(Integer)
63
+ when 'Time'
64
+ return Time.parse(data)
65
+ when 'Date'
66
+ return Date.parse(data)
67
+ when 'String'
68
+ return data if data.instance_of?(String)
69
+ when 'Object' # "type: object"
70
+ return data if data.instance_of?(Hash)
71
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
72
+ if data.instance_of?(Array)
73
+ sub_type = Regexp.last_match[:sub_type]
74
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
75
+ end
76
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
77
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
78
+ sub_type = Regexp.last_match[:sub_type]
79
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
80
+ end
81
+ else # model
82
+ const = Fastly.const_get(klass)
83
+ if const
84
+ if const.respond_to?(:fastly_one_of) # nested oneOf model
85
+ model = const.build(data)
86
+ return model if model
87
+ else
88
+ # raise if data contains keys that are not known to the model
89
+ raise unless (data.keys - const.acceptable_attributes).empty?
90
+ model = const.build_from_hash(data)
91
+ return model if model && model.valid?
92
+ end
93
+ end
94
+ end
95
+
96
+ raise # if no match by now, raise
97
+ rescue
98
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
99
+ end
100
+ end
101
+ end
102
+
103
+ end