contentful-management 1.10.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +48 -0
  4. data/README.md +92 -50
  5. data/lib/contentful/management/api_key.rb +25 -2
  6. data/lib/contentful/management/array.rb +3 -3
  7. data/lib/contentful/management/asset.rb +13 -8
  8. data/lib/contentful/management/client.rb +73 -60
  9. data/lib/contentful/management/client_api_key_methods_factory.rb +8 -0
  10. data/lib/contentful/management/client_asset_methods_factory.rb +0 -2
  11. data/lib/contentful/management/client_association_all_published_method_factory.rb +2 -3
  12. data/lib/contentful/management/client_association_methods_factory.rb +9 -9
  13. data/lib/contentful/management/client_content_type_methods_factory.rb +8 -2
  14. data/lib/contentful/management/client_editor_interface_methods_factory.rb +12 -6
  15. data/lib/contentful/management/client_entry_methods_factory.rb +1 -3
  16. data/lib/contentful/management/client_environment_methods_factory.rb +59 -0
  17. data/lib/contentful/management/client_organization_methods_factory.rb +1 -1
  18. data/lib/contentful/management/client_personal_access_tokens_methods_factory.rb +3 -3
  19. data/lib/contentful/management/client_role_methods_factory.rb +8 -0
  20. data/lib/contentful/management/client_snapshot_methods_factory.rb +8 -6
  21. data/lib/contentful/management/client_space_methods_factory.rb +2 -6
  22. data/lib/contentful/management/client_upload_methods_factory.rb +8 -0
  23. data/lib/contentful/management/client_user_methods_factory.rb +1 -1
  24. data/lib/contentful/management/client_webhook_call_methods_factory.rb +11 -6
  25. data/lib/contentful/management/client_webhook_health_methods_factory.rb +2 -2
  26. data/lib/contentful/management/client_webhook_methods_factory.rb +8 -0
  27. data/lib/contentful/management/content_type.rb +9 -7
  28. data/lib/contentful/management/content_type_editor_interface_methods_factory.rb +7 -3
  29. data/lib/contentful/management/content_type_entry_methods_factory.rb +2 -2
  30. data/lib/contentful/management/content_type_snapshot_methods_factory.rb +16 -2
  31. data/lib/contentful/management/dynamic_entry.rb +1 -1
  32. data/lib/contentful/management/editor_interface.rb +14 -6
  33. data/lib/contentful/management/entry.rb +12 -10
  34. data/lib/contentful/management/entry_association_methods_factory.rb +2 -2
  35. data/lib/contentful/management/environment.rb +138 -0
  36. data/lib/contentful/management/environment_asset_methods_factory.rb +11 -0
  37. data/lib/contentful/management/environment_association_methods_factory.rb +42 -0
  38. data/lib/contentful/management/environment_content_type_methods_factory.rb +11 -0
  39. data/lib/contentful/management/environment_editor_interface_methods_factory.rb +15 -0
  40. data/lib/contentful/management/environment_entry_methods_factory.rb +11 -0
  41. data/lib/contentful/management/environment_locale_methods_factory.rb +11 -0
  42. data/lib/contentful/management/environment_ui_extension_methods_factory.rb +11 -0
  43. data/lib/contentful/management/field.rb +3 -3
  44. data/lib/contentful/management/file.rb +2 -2
  45. data/lib/contentful/management/link.rb +21 -7
  46. data/lib/contentful/management/locale.rb +4 -2
  47. data/lib/contentful/management/organization.rb +1 -1
  48. data/lib/contentful/management/personal_access_token.rb +2 -2
  49. data/lib/contentful/management/resource.rb +34 -13
  50. data/lib/contentful/management/resource/all_published.rb +2 -2
  51. data/lib/contentful/management/resource/archiver.rb +12 -2
  52. data/lib/contentful/management/resource/environment_aware.rb +13 -0
  53. data/lib/contentful/management/resource/publisher.rb +12 -2
  54. data/lib/contentful/management/resource/refresher.rb +1 -1
  55. data/lib/contentful/management/resource_builder.rb +16 -14
  56. data/lib/contentful/management/response.rb +1 -1
  57. data/lib/contentful/management/role.rb +29 -2
  58. data/lib/contentful/management/snapshot.rb +13 -7
  59. data/lib/contentful/management/space.rb +14 -93
  60. data/lib/contentful/management/space_association_methods_factory.rb +1 -1
  61. data/lib/contentful/management/{space_locale_methods_factory.rb → space_environment_methods_factory.rb} +2 -6
  62. data/lib/contentful/management/space_membership.rb +3 -3
  63. data/lib/contentful/management/ui_extension.rb +4 -2
  64. data/lib/contentful/management/upload.rb +24 -1
  65. data/lib/contentful/management/user.rb +4 -4
  66. data/lib/contentful/management/validation.rb +5 -5
  67. data/lib/contentful/management/version.rb +1 -1
  68. data/lib/contentful/management/webhook.rb +26 -3
  69. data/lib/contentful/management/webhook_call.rb +8 -8
  70. data/lib/contentful/management/webhook_health.rb +2 -2
  71. data/spec/fixtures/vcr_cassettes/asset/143_assets_next_page.yml +2 -2
  72. data/spec/fixtures/vcr_cassettes/asset/all.yml +1 -1
  73. data/spec/fixtures/vcr_cassettes/asset/archive.yml +2 -2
  74. data/spec/fixtures/vcr_cassettes/asset/archive_published.yml +2 -2
  75. data/spec/fixtures/vcr_cassettes/asset/archived_false.yml +2 -2
  76. data/spec/fixtures/vcr_cassettes/asset/archived_true.yml +2 -2
  77. data/spec/fixtures/vcr_cassettes/asset/create.yml +2 -2
  78. data/spec/fixtures/vcr_cassettes/asset/create_with_already_used_id.yml +1 -1
  79. data/spec/fixtures/vcr_cassettes/asset/create_with_custom_id.yml +2 -2
  80. data/spec/fixtures/vcr_cassettes/asset/create_with_locale.yml +2 -2
  81. data/spec/fixtures/vcr_cassettes/asset/destroy.yml +2 -2
  82. data/spec/fixtures/vcr_cassettes/asset/destroy_published.yml +2 -2
  83. data/spec/fixtures/vcr_cassettes/asset/find.yml +1 -1
  84. data/spec/fixtures/vcr_cassettes/asset/find_not_found.yml +1 -1
  85. data/spec/fixtures/vcr_cassettes/asset/limited_assets_next_page.yml +2 -2
  86. data/spec/fixtures/vcr_cassettes/asset/locale.yml +1 -1
  87. data/spec/fixtures/vcr_cassettes/asset/process.yml +2 -2
  88. data/spec/fixtures/vcr_cassettes/asset/publish.yml +2 -2
  89. data/spec/fixtures/vcr_cassettes/asset/publish_after_create.yml +3 -3
  90. data/spec/fixtures/vcr_cassettes/asset/publish_already_published.yml +2 -2
  91. data/spec/fixtures/vcr_cassettes/asset/published_false.yml +2 -2
  92. data/spec/fixtures/vcr_cassettes/asset/published_true.yml +2 -2
  93. data/spec/fixtures/vcr_cassettes/asset/reload.yml +4 -4
  94. data/spec/fixtures/vcr_cassettes/asset/reload_with_fields.yml +2 -2
  95. data/spec/fixtures/vcr_cassettes/asset/save_update.yml +2 -2
  96. data/spec/fixtures/vcr_cassettes/asset/select_operator.yml +1 -1
  97. data/spec/fixtures/vcr_cassettes/asset/set_locale.yml +1 -1
  98. data/spec/fixtures/vcr_cassettes/asset/unarchive.yml +2 -2
  99. data/spec/fixtures/vcr_cassettes/asset/unarchive_already_unarchive.yml +2 -2
  100. data/spec/fixtures/vcr_cassettes/asset/unarchive_already_unarchived.yml +2 -2
  101. data/spec/fixtures/vcr_cassettes/asset/unpublish.yml +2 -2
  102. data/spec/fixtures/vcr_cassettes/asset/unpublish_already_unpublished.yml +2 -2
  103. data/spec/fixtures/vcr_cassettes/asset/update_file.yml +2 -2
  104. data/spec/fixtures/vcr_cassettes/asset/update_to_specified_locale.yml +2 -2
  105. data/spec/fixtures/vcr_cassettes/asset/update_with_default_locale_without_file.yml +2 -2
  106. data/spec/fixtures/vcr_cassettes/content_type/activate.yml +2 -2
  107. data/spec/fixtures/vcr_cassettes/content_type/activate_with_invalid_version.yml +2 -2
  108. data/spec/fixtures/vcr_cassettes/content_type/activated_false.yml +2 -2
  109. data/spec/fixtures/vcr_cassettes/content_type/activated_true.yml +2 -2
  110. data/spec/fixtures/vcr_cassettes/content_type/all.yml +1 -1
  111. data/spec/fixtures/vcr_cassettes/content_type/all_public.yml +1 -1
  112. data/spec/fixtures/vcr_cassettes/content_type/create.yml +1 -1
  113. data/spec/fixtures/vcr_cassettes/content_type/create_content_type_with_id.yml +1 -1
  114. data/spec/fixtures/vcr_cassettes/content_type/create_with_Array_field.yml +1 -1
  115. data/spec/fixtures/vcr_cassettes/content_type/create_with_Boolean_field.yml +1 -1
  116. data/spec/fixtures/vcr_cassettes/content_type/create_with_Date_field.yml +1 -1
  117. data/spec/fixtures/vcr_cassettes/content_type/create_with_Integer_field.yml +1 -1
  118. data/spec/fixtures/vcr_cassettes/content_type/create_with_Link_field.yml +1 -1
  119. data/spec/fixtures/vcr_cassettes/content_type/create_with_Location_field.yml +1 -1
  120. data/spec/fixtures/vcr_cassettes/content_type/create_with_Number_field.yml +1 -1
  121. data/spec/fixtures/vcr_cassettes/content_type/create_with_Object_field.yml +1 -1
  122. data/spec/fixtures/vcr_cassettes/content_type/create_with_Symbol_field.yml +1 -1
  123. data/spec/fixtures/vcr_cassettes/content_type/create_with_Text_field.yml +1 -1
  124. data/spec/fixtures/vcr_cassettes/content_type/deactivate.yml +2 -2
  125. data/spec/fixtures/vcr_cassettes/content_type/deactivate_already_deactivated.yml +2 -2
  126. data/spec/fixtures/vcr_cassettes/content_type/deactivate_with_entries.yml +2 -2
  127. data/spec/fixtures/vcr_cassettes/content_type/deactivate_with_version_change.yml +2 -2
  128. data/spec/fixtures/vcr_cassettes/content_type/destroy.yml +2 -2
  129. data/spec/fixtures/vcr_cassettes/content_type/destroy_activated.yml +2 -2
  130. data/spec/fixtures/vcr_cassettes/content_type/entry/all.yml +4 -4
  131. data/spec/fixtures/vcr_cassettes/content_type/entry/create.yml +4 -4
  132. data/spec/fixtures/vcr_cassettes/content_type/entry/create_only_with_localized_fields.yml +2 -2
  133. data/spec/fixtures/vcr_cassettes/content_type/entry/create_to_single_locale_only_with_localized_fields.yml +2 -2
  134. data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_camel_case_id_to_multiple_locales.yml +2 -2
  135. data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries.yml +3 -3
  136. data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries_for_multiple_locales.yml +9 -9
  137. data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_multiple_locales.yml +2 -2
  138. data/spec/fixtures/vcr_cassettes/content_type/entry/update_only_with_localized_fields.yml +3 -3
  139. data/spec/fixtures/vcr_cassettes/content_type/fields/add.yml +2 -2
  140. data/spec/fixtures/vcr_cassettes/content_type/fields/create.yml +2 -2
  141. data/spec/fixtures/vcr_cassettes/content_type/fields/create_array_types.yml +3 -3
  142. data/spec/fixtures/vcr_cassettes/content_type/fields/create_array_with_params.yml +2 -2
  143. data/spec/fixtures/vcr_cassettes/content_type/fields/create_with_params.yml +2 -2
  144. data/spec/fixtures/vcr_cassettes/content_type/fields/destroy.yml +2 -2
  145. data/spec/fixtures/vcr_cassettes/content_type/fields/update_field.yml +2 -2
  146. data/spec/fixtures/vcr_cassettes/content_type/find.yml +1 -1
  147. data/spec/fixtures/vcr_cassettes/content_type/find_not_found.yml +1 -1
  148. data/spec/fixtures/vcr_cassettes/content_type/issue_79.yml +3 -3
  149. data/spec/fixtures/vcr_cassettes/content_type/omitted_field.yml +4 -4
  150. data/spec/fixtures/vcr_cassettes/content_type/reload.yml +4 -4
  151. data/spec/fixtures/vcr_cassettes/content_type/save_new.yml +3 -3
  152. data/spec/fixtures/vcr_cassettes/content_type/save_updated.yml +2 -2
  153. data/spec/fixtures/vcr_cassettes/content_type/save_with_added_field.yml +2 -2
  154. data/spec/fixtures/vcr_cassettes/content_type/update.yml +2 -2
  155. data/spec/fixtures/vcr_cassettes/content_type/update_change_field_name.yml +2 -2
  156. data/spec/fixtures/vcr_cassettes/content_type/update_remove_field.yml +2 -2
  157. data/spec/fixtures/vcr_cassettes/content_type/update_with_fields.yml +2 -2
  158. data/spec/fixtures/vcr_cassettes/content_type/update_with_one_new_field.yml +2 -2
  159. data/spec/fixtures/vcr_cassettes/content_type/validation/in.yml +3 -3
  160. data/spec/fixtures/vcr_cassettes/content_type/validation/in_add.yml +3 -3
  161. data/spec/fixtures/vcr_cassettes/content_type/validation/in_update.yml +3 -3
  162. data/spec/fixtures/vcr_cassettes/content_type/validation/link_content_type.yml +3 -3
  163. data/spec/fixtures/vcr_cassettes/content_type/validation/link_field.yml +3 -3
  164. data/spec/fixtures/vcr_cassettes/content_type/validation/link_mimetype_group.yml +3 -3
  165. data/spec/fixtures/vcr_cassettes/content_type/validation/multiple_add.yml +3 -3
  166. data/spec/fixtures/vcr_cassettes/content_type/validation/present.yml +3 -3
  167. data/spec/fixtures/vcr_cassettes/content_type/validation/range.yml +3 -3
  168. data/spec/fixtures/vcr_cassettes/content_type/validation/range_update.yml +3 -3
  169. data/spec/fixtures/vcr_cassettes/content_type/validation/regexp.yml +3 -3
  170. data/spec/fixtures/vcr_cassettes/content_type/validation/size.yml +3 -3
  171. data/spec/fixtures/vcr_cassettes/content_type/validation/unique.yml +3 -3
  172. data/spec/fixtures/vcr_cassettes/editor_interfaces/default_for_space.yml +1 -1
  173. data/spec/fixtures/vcr_cassettes/editor_interfaces/update.yml +3 -3
  174. data/spec/fixtures/vcr_cassettes/entry/all.yml +1 -1
  175. data/spec/fixtures/vcr_cassettes/entry/archive.yml +2 -2
  176. data/spec/fixtures/vcr_cassettes/entry/archive_published.yml +2 -2
  177. data/spec/fixtures/vcr_cassettes/entry/archived_false.yml +2 -2
  178. data/spec/fixtures/vcr_cassettes/entry/archived_true.yml +2 -2
  179. data/spec/fixtures/vcr_cassettes/entry/content_type_entires.yml +1 -1
  180. data/spec/fixtures/vcr_cassettes/entry/create.yml +4 -4
  181. data/spec/fixtures/vcr_cassettes/entry/create_with_asset.yml +3 -3
  182. data/spec/fixtures/vcr_cassettes/entry/create_with_assets.yml +3 -3
  183. data/spec/fixtures/vcr_cassettes/entry/create_with_custom_id.yml +2 -2
  184. data/spec/fixtures/vcr_cassettes/entry/create_with_entries.yml +3 -3
  185. data/spec/fixtures/vcr_cassettes/entry/create_with_entry.yml +3 -3
  186. data/spec/fixtures/vcr_cassettes/entry/create_with_just_id.yml +4 -4
  187. data/spec/fixtures/vcr_cassettes/entry/create_with_location.yml +2 -2
  188. data/spec/fixtures/vcr_cassettes/entry/create_with_specified_locale.yml +3 -3
  189. data/spec/fixtures/vcr_cassettes/entry/create_with_symbols.yml +2 -2
  190. data/spec/fixtures/vcr_cassettes/entry/destory_published.yml +2 -2
  191. data/spec/fixtures/vcr_cassettes/entry/destroy.yml +2 -2
  192. data/spec/fixtures/vcr_cassettes/entry/fallback_undefined.yml +3 -3
  193. data/spec/fixtures/vcr_cassettes/entry/find-with-null-symbols.yml +2 -2
  194. data/spec/fixtures/vcr_cassettes/entry/find.yml +1 -1
  195. data/spec/fixtures/vcr_cassettes/entry/find_not_found.yml +1 -1
  196. data/spec/fixtures/vcr_cassettes/entry/issue_61_1.yml +6 -6
  197. data/spec/fixtures/vcr_cassettes/entry/issue_61_2.yml +6 -6
  198. data/spec/fixtures/vcr_cassettes/entry/issue_61_3.yml +6 -6
  199. data/spec/fixtures/vcr_cassettes/entry/issue_61_4.yml +6 -6
  200. data/spec/fixtures/vcr_cassettes/entry/issue_61_5.yml +305 -198
  201. data/spec/fixtures/vcr_cassettes/entry/issue_61_6.yml +5 -5
  202. data/spec/fixtures/vcr_cassettes/entry/issue_61_7.yml +6 -6
  203. data/spec/fixtures/vcr_cassettes/entry/issue_61_8.yml +6 -6
  204. data/spec/fixtures/vcr_cassettes/entry/issue_61_spaces.yml +143 -188
  205. data/spec/fixtures/vcr_cassettes/entry/issue_70.yml +3 -3
  206. data/spec/fixtures/vcr_cassettes/entry/issue_73.yml +4 -4
  207. data/spec/fixtures/vcr_cassettes/entry/issue_91.yml +2 -2
  208. data/spec/fixtures/vcr_cassettes/entry/limited_entries.yml +2 -2
  209. data/spec/fixtures/vcr_cassettes/entry/locales/fallback_to_default_locale.yml +2 -2
  210. data/spec/fixtures/vcr_cassettes/entry/locales/retrieve_localized.yml +2 -2
  211. data/spec/fixtures/vcr_cassettes/entry/locales/simple_assignments_use_default_locale.yml +2 -2
  212. data/spec/fixtures/vcr_cassettes/entry/locales/simple_assignments_use_specified_locale.yml +2 -2
  213. data/spec/fixtures/vcr_cassettes/entry/publish.yml +2 -2
  214. data/spec/fixtures/vcr_cassettes/entry/publish_already_published.yml +2 -2
  215. data/spec/fixtures/vcr_cassettes/entry/published_false.yml +2 -2
  216. data/spec/fixtures/vcr_cassettes/entry/published_true.yml +2 -2
  217. data/spec/fixtures/vcr_cassettes/entry/reload.yml +6 -6
  218. data/spec/fixtures/vcr_cassettes/entry/save_update.yml +2 -2
  219. data/spec/fixtures/vcr_cassettes/entry/search_filter/equality_operator.yml +2 -2
  220. data/spec/fixtures/vcr_cassettes/entry/search_filter/exclusion_operator.yml +2 -2
  221. data/spec/fixtures/vcr_cassettes/entry/search_filter/full_search.yml +2 -2
  222. data/spec/fixtures/vcr_cassettes/entry/search_filter/full_search_match_operator.yml +2 -2
  223. data/spec/fixtures/vcr_cassettes/entry/search_filter/including_linked_entries.yml +2 -2
  224. data/spec/fixtures/vcr_cassettes/entry/search_filter/inclusion_operator.yml +2 -2
  225. data/spec/fixtures/vcr_cassettes/entry/search_filter/inequality_operator.yml +2 -2
  226. data/spec/fixtures/vcr_cassettes/entry/search_filter/location_search_near_operator.yml +2 -2
  227. data/spec/fixtures/vcr_cassettes/entry/search_filter/location_search_within_operator.yml +2 -2
  228. data/spec/fixtures/vcr_cassettes/entry/search_filter/matching_array_fields.yml +2 -2
  229. data/spec/fixtures/vcr_cassettes/entry/search_filter/order_sys_createdAt.yml +2 -2
  230. data/spec/fixtures/vcr_cassettes/entry/search_filter/order_sys_updatedAt.yml +2 -2
  231. data/spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_greater_than_or_equal.yml +2 -2
  232. data/spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_less.yml +2 -2
  233. data/spec/fixtures/vcr_cassettes/entry/search_filter/reverse_order_sys_updatedAt.yml +2 -2
  234. data/spec/fixtures/vcr_cassettes/entry/select_operator.yml +1 -1
  235. data/spec/fixtures/vcr_cassettes/entry/service_unavailable.yml +1 -1
  236. data/spec/fixtures/vcr_cassettes/entry/too_many_requests.yml +5 -5
  237. data/spec/fixtures/vcr_cassettes/entry/too_many_requests_retry.yml +6 -6
  238. data/spec/fixtures/vcr_cassettes/entry/unarchive.yml +2 -2
  239. data/spec/fixtures/vcr_cassettes/entry/unarchive_already_unarchived.yml +2 -2
  240. data/spec/fixtures/vcr_cassettes/entry/unpublish.yml +2 -2
  241. data/spec/fixtures/vcr_cassettes/entry/unpublish_already_unpublished.yml +2 -2
  242. data/spec/fixtures/vcr_cassettes/entry/update.yml +4 -4
  243. data/spec/fixtures/vcr_cassettes/entry/update_bool_field.yml +4 -4
  244. data/spec/fixtures/vcr_cassettes/entry/update_unlocalized_field.yml +3 -3
  245. data/spec/fixtures/vcr_cassettes/entry/update_with_custom_locale.yml +3 -3
  246. data/spec/fixtures/vcr_cassettes/environment/all.yml +226 -0
  247. data/spec/fixtures/vcr_cassettes/environment/create.yml +155 -0
  248. data/spec/fixtures/vcr_cassettes/environment/destroy.yml +89 -0
  249. data/spec/fixtures/vcr_cassettes/environment/find.yml +155 -0
  250. data/spec/fixtures/vcr_cassettes/environment/find_2.yml +155 -0
  251. data/spec/fixtures/vcr_cassettes/environment/not_found.yml +98 -0
  252. data/spec/fixtures/vcr_cassettes/locale/all_for_space.yml +1 -1
  253. data/spec/fixtures/vcr_cassettes/locale/create_for_space.yml +2 -2
  254. data/spec/fixtures/vcr_cassettes/locale/destroy.yml +5 -5
  255. data/spec/fixtures/vcr_cassettes/locale/fallback_code.yml +3 -3
  256. data/spec/fixtures/vcr_cassettes/locale/find.yml +1 -1
  257. data/spec/fixtures/vcr_cassettes/locale/find_default.yml +1 -1
  258. data/spec/fixtures/vcr_cassettes/locale/find_for_space_not_found.yml +1 -1
  259. data/spec/fixtures/vcr_cassettes/locale/find_not_default.yml +1 -1
  260. data/spec/fixtures/vcr_cassettes/locale/find_not_optional.yml +1 -1
  261. data/spec/fixtures/vcr_cassettes/locale/find_optional.yml +1 -1
  262. data/spec/fixtures/vcr_cassettes/locale/reload.yml +3 -3
  263. data/spec/fixtures/vcr_cassettes/locale/update_both.yml +3 -3
  264. data/spec/fixtures/vcr_cassettes/locale/update_code.yml +3 -3
  265. data/spec/fixtures/vcr_cassettes/locale/update_name.yml +3 -3
  266. data/spec/fixtures/vcr_cassettes/snapshot/all.yml +1 -1
  267. data/spec/fixtures/vcr_cassettes/snapshot/ct_all.yml +1 -1
  268. data/spec/fixtures/vcr_cassettes/snapshot/ct_find.yml +1 -1
  269. data/spec/fixtures/vcr_cassettes/snapshot/ct_find_not_found.yml +1 -1
  270. data/spec/fixtures/vcr_cassettes/snapshot/find.yml +1 -1
  271. data/spec/fixtures/vcr_cassettes/snapshot/find_not_found.yml +1 -1
  272. data/spec/fixtures/vcr_cassettes/snapshot/properties.yml +2 -2
  273. data/spec/fixtures/vcr_cassettes/ui_extension/all.yml +1 -1
  274. data/spec/fixtures/vcr_cassettes/ui_extension/create.yml +1 -1
  275. data/spec/fixtures/vcr_cassettes/ui_extension/delete.yml +3 -3
  276. data/spec/fixtures/vcr_cassettes/ui_extension/find.yml +1 -1
  277. data/spec/fixtures/vcr_cassettes/upload/associate_with_asset.yml +3 -3
  278. data/spec/lib/contentful/management/api_key_spec.rb +7 -7
  279. data/spec/lib/contentful/management/asset_spec.rb +38 -57
  280. data/spec/lib/contentful/management/client_spec.rb +1 -1
  281. data/spec/lib/contentful/management/content_type_spec.rb +78 -78
  282. data/spec/lib/contentful/management/editor_interface_spec.rb +4 -4
  283. data/spec/lib/contentful/management/entry_spec.rb +104 -114
  284. data/spec/lib/contentful/management/environment_spec.rb +87 -0
  285. data/spec/lib/contentful/management/locale_spec.rb +22 -22
  286. data/spec/lib/contentful/management/role_spec.rb +11 -11
  287. data/spec/lib/contentful/management/snapshot_spec.rb +27 -27
  288. data/spec/lib/contentful/management/space_membership_spec.rb +6 -7
  289. data/spec/lib/contentful/management/space_spec.rb +0 -282
  290. data/spec/lib/contentful/management/ui_extension_spec.rb +8 -8
  291. data/spec/lib/contentful/management/upload_spec.rb +9 -9
  292. data/spec/lib/contentful/management/webhook_calls_spec.rb +6 -6
  293. data/spec/lib/contentful/management/webhook_health_spec.rb +3 -3
  294. data/spec/lib/contentful/management/webhook_spec.rb +14 -12
  295. metadata +28 -14
  296. data/lib/contentful/management/space_asset_methods_factory.rb +0 -13
  297. data/lib/contentful/management/space_association_all_published_method_factory.rb +0 -12
  298. data/lib/contentful/management/space_content_type_methods_factory.rb +0 -13
  299. data/lib/contentful/management/space_editor_interface_methods_factory.rb +0 -21
  300. data/lib/contentful/management/space_entry_methods_factory.rb +0 -21
  301. data/lib/contentful/management/space_ui_extension_methods_factory.rb +0 -15
  302. data/spec/fixtures/vcr_cassettes/asset/all_public.yml +0 -112
  303. data/spec/fixtures/vcr_cassettes/entry/all_public.yml +0 -102
@@ -1,23 +1,24 @@
1
1
  require_relative 'resource'
2
- require_relative 'resource/asset_fields'
3
- require_relative 'resource/all_published'
4
2
  require_relative 'resource/fields'
5
3
  require_relative 'resource/archiver'
6
4
  require_relative 'resource/publisher'
5
+ require_relative 'resource/asset_fields'
6
+ require_relative 'resource/environment_aware'
7
7
 
8
8
  module Contentful
9
9
  module Management
10
10
  # Resource class for Asset.
11
11
  # @see _ https://www.contentful.com/developers/documentation/content-management-api/#resources-assets
12
12
  class Asset
13
- include Contentful::Management::Resource
14
13
  extend Contentful::Management::Resource::AssetFields
15
- extend Contentful::Management::Resource::AllPublished
14
+
15
+ include Contentful::Management::Resource
16
16
  include Contentful::Management::Resource::Fields
17
- include Contentful::Management::Resource::SystemProperties
18
- include Contentful::Management::Resource::Refresher
19
17
  include Contentful::Management::Resource::Archiver
18
+ include Contentful::Management::Resource::Refresher
20
19
  include Contentful::Management::Resource::Publisher
20
+ include Contentful::Management::Resource::SystemProperties
21
+ include Contentful::Management::Resource::EnvironmentAware
21
22
 
22
23
  # @private
23
24
  def self.client_association_class
@@ -53,7 +54,7 @@ module Contentful
53
54
  instance_variable_get(:@fields).keys.each do |locale|
54
55
  request = Request.new(
55
56
  client,
56
- "spaces/#{space.id}/assets/#{id}/files/#{locale}/process",
57
+ process_url(locale),
57
58
  {},
58
59
  nil,
59
60
  version: sys[:version]
@@ -77,7 +78,7 @@ module Contentful
77
78
  end
78
79
  end
79
80
 
80
- # Returns currently supported local or default locale.
81
+ # Returns currently supported locale or default locale.
81
82
  # @return [String] current_locale
82
83
  def locale
83
84
  sys && sys[:locale] ? sys[:locale] : default_locale
@@ -124,6 +125,10 @@ module Contentful
124
125
 
125
126
  protected
126
127
 
128
+ def process_url(locale_code)
129
+ "spaces/#{space.id}/environments/#{environment_id}/assets/#{id}/files/#{locale_code}/process"
130
+ end
131
+
127
132
  def query_attributes(attributes)
128
133
  self.title = attributes[:title] if attributes[:title]
129
134
  self.description = attributes[:description] if attributes[:description]
@@ -1,33 +1,34 @@
1
+ require 'http'
2
+ require 'json'
3
+ require 'logger'
4
+ require 'rbconfig'
5
+
6
+ require_relative 'request'
7
+
1
8
  require 'contentful/management'
9
+ require 'contentful/management/version'
2
10
  require 'contentful/management/response'
3
11
  require 'contentful/management/resource_builder'
4
12
 
5
- require 'contentful/management/version'
6
-
7
- require 'contentful/management/client_space_methods_factory'
8
- require 'contentful/management/client_space_membership_methods_factory'
9
- require 'contentful/management/client_organization_methods_factory'
13
+ require 'contentful/management/client_role_methods_factory'
10
14
  require 'contentful/management/client_user_methods_factory'
11
- require 'contentful/management/client_api_key_methods_factory'
12
- require 'contentful/management/client_personal_access_tokens_methods_factory'
15
+ require 'contentful/management/client_space_methods_factory'
13
16
  require 'contentful/management/client_asset_methods_factory'
14
- require 'contentful/management/client_content_type_methods_factory'
15
17
  require 'contentful/management/client_entry_methods_factory'
16
18
  require 'contentful/management/client_locale_methods_factory'
17
- require 'contentful/management/client_role_methods_factory'
18
- require 'contentful/management/client_ui_extension_methods_factory'
19
- require 'contentful/management/client_editor_interface_methods_factory'
19
+ require 'contentful/management/client_upload_methods_factory'
20
+ require 'contentful/management/client_api_key_methods_factory'
20
21
  require 'contentful/management/client_webhook_methods_factory'
22
+ require 'contentful/management/client_snapshot_methods_factory'
23
+ require 'contentful/management/client_environment_methods_factory'
24
+ require 'contentful/management/client_organization_methods_factory'
25
+ require 'contentful/management/client_content_type_methods_factory'
26
+ require 'contentful/management/client_ui_extension_methods_factory'
21
27
  require 'contentful/management/client_webhook_call_methods_factory'
22
28
  require 'contentful/management/client_webhook_health_methods_factory'
23
- require 'contentful/management/client_upload_methods_factory'
24
- require 'contentful/management/client_snapshot_methods_factory'
25
-
26
- require_relative 'request'
27
- require 'http'
28
- require 'json'
29
- require 'logger'
30
- require 'rbconfig'
29
+ require 'contentful/management/client_space_membership_methods_factory'
30
+ require 'contentful/management/client_editor_interface_methods_factory'
31
+ require 'contentful/management/client_personal_access_tokens_methods_factory'
31
32
 
32
33
  module Contentful
33
34
  module Management
@@ -48,7 +49,7 @@ module Contentful
48
49
  logger: false,
49
50
  log_level: Logger::INFO,
50
51
  raise_errors: false,
51
- dynamic_entries: [],
52
+ dynamic_entries: {},
52
53
  disable_content_type_caching: false,
53
54
  proxy_host: nil,
54
55
  proxy_port: nil,
@@ -94,7 +95,7 @@ module Contentful
94
95
  end
95
96
 
96
97
  # Allows manipulation of spaces in context of the current client
97
- # Allows listing all spaces for client and finding one by ID.
98
+ # Allows listing all spaces for client, creating new and finding one by ID.
98
99
  # @see _ README for details.
99
100
  #
100
101
  # @return [Contentful::Management::ClientSpaceMethodsFactory]
@@ -102,13 +103,22 @@ module Contentful
102
103
  ClientSpaceMethodsFactory.new(self)
103
104
  end
104
105
 
106
+ # Allows manipulation of environments in context of the current client
107
+ # Allows listing all environments for client, creating new and finding one by ID.
108
+ # @see _ README for details.
109
+ #
110
+ # @return [Contentful::Management::ClientEnvironmentMethodsFactory]
111
+ def environments(space_id)
112
+ ClientEnvironmentMethodsFactory.new(self, space_id)
113
+ end
114
+
105
115
  # Allows manipulation of space memberships in context of the current client
106
116
  # Allows listing all space memberships for client, creating new and finding one by ID.
107
117
  # @see _ README for details.
108
118
  #
109
119
  # @return [Contentful::Management::ClientSpaceMembershipMethodsFactory]
110
- def space_memberships
111
- ClientSpaceMembershipMethodsFactory.new(self)
120
+ def space_memberships(space_id)
121
+ ClientSpaceMembershipMethodsFactory.new(self, space_id)
112
122
  end
113
123
 
114
124
  # Allows viewing of organizations in context of the current client
@@ -134,8 +144,8 @@ module Contentful
134
144
  # @see _ README for details.
135
145
  #
136
146
  # @return [Contentful::Management::ClientApiKeyMethodsFactory]
137
- def api_keys
138
- ClientApiKeyMethodsFactory.new(self)
147
+ def api_keys(space_id)
148
+ ClientApiKeyMethodsFactory.new(self, space_id)
139
149
  end
140
150
 
141
151
  # Allows manipulation of personal access tokens in context of the current client
@@ -152,8 +162,8 @@ module Contentful
152
162
  # @see _ README for details.
153
163
  #
154
164
  # @return [Contentful::Management::ClientAssetMethodsFactory]
155
- def assets
156
- ClientAssetMethodsFactory.new(self)
165
+ def assets(space_id, environment_id)
166
+ ClientAssetMethodsFactory.new(self, space_id, environment_id)
157
167
  end
158
168
 
159
169
  # Allows manipulation of content types in context of the current client
@@ -161,8 +171,8 @@ module Contentful
161
171
  # @see _ README for details.
162
172
  #
163
173
  # @return [Contentful::Management::ClientContentTypeMethodsFactory]
164
- def content_types
165
- ClientContentTypeMethodsFactory.new(self)
174
+ def content_types(space_id, environment_id)
175
+ ClientContentTypeMethodsFactory.new(self, space_id, environment_id)
166
176
  end
167
177
 
168
178
  # Allows manipulation of entries in context of the current client
@@ -170,8 +180,8 @@ module Contentful
170
180
  # @see _ README for details.
171
181
  #
172
182
  # @return [Contentful::Management::ClientEntryMethodsFactory]
173
- def entries
174
- ClientEntryMethodsFactory.new(self)
183
+ def entries(space_id, environment_id)
184
+ ClientEntryMethodsFactory.new(self, space_id, environment_id)
175
185
  end
176
186
 
177
187
  # Allows manipulation of locales in context of the current client
@@ -179,8 +189,8 @@ module Contentful
179
189
  # @see _ README for details.
180
190
  #
181
191
  # @return [Contentful::Management::ClientLocaleMethodsFactory]
182
- def locales
183
- ClientLocaleMethodsFactory.new(self)
192
+ def locales(space_id, environment_id)
193
+ ClientLocaleMethodsFactory.new(self, space_id, environment_id)
184
194
  end
185
195
 
186
196
  # Allows manipulation of roles in context of the current client
@@ -188,8 +198,8 @@ module Contentful
188
198
  # @see _ README for details.
189
199
  #
190
200
  # @return [Contentful::Management::ClientRoleMethodsFactory]
191
- def roles
192
- ClientRoleMethodsFactory.new(self)
201
+ def roles(space_id)
202
+ ClientRoleMethodsFactory.new(self, space_id)
193
203
  end
194
204
 
195
205
  # Allows manipulation of UI extensions in context of the current client
@@ -197,8 +207,8 @@ module Contentful
197
207
  # @see _ README for details.
198
208
  #
199
209
  # @return [Contentful::Management::ClientUIExtensionMethodsFactory]
200
- def ui_extensions
201
- ClientUIExtensionMethodsFactory.new(self)
210
+ def ui_extensions(space_id, environment_id)
211
+ ClientUIExtensionMethodsFactory.new(self, space_id, environment_id)
202
212
  end
203
213
 
204
214
  # Allows manipulation of editor interfaces in context of the current client
@@ -206,8 +216,8 @@ module Contentful
206
216
  # @see _ README for details.
207
217
  #
208
218
  # @return [Contentful::Management::ClientEditorInterfaceMethodsFactory]
209
- def editor_interfaces
210
- ClientEditorInterfaceMethodsFactory.new(self)
219
+ def editor_interfaces(space_id, environment_id, content_type_id)
220
+ ClientEditorInterfaceMethodsFactory.new(self, space_id, environment_id, content_type_id)
211
221
  end
212
222
 
213
223
  # Allows manipulation of webhooks in context of the current client
@@ -215,8 +225,8 @@ module Contentful
215
225
  # @see _ README for details.
216
226
  #
217
227
  # @return [Contentful::Management::ClientWebhookMethodsFactory]
218
- def webhooks
219
- ClientWebhookMethodsFactory.new(self)
228
+ def webhooks(space_id)
229
+ ClientWebhookMethodsFactory.new(self, space_id)
220
230
  end
221
231
 
222
232
  # Allows manipulation of webhook calls in context of the current client
@@ -224,8 +234,8 @@ module Contentful
224
234
  # @see _ README for details.
225
235
  #
226
236
  # @return [Contentful::Management::ClientWebhookCallMethodsFactory]
227
- def webhook_calls
228
- ClientWebhookCallMethodsFactory.new(self)
237
+ def webhook_calls(space_id, webhook_id)
238
+ ClientWebhookCallMethodsFactory.new(self, space_id, webhook_id)
229
239
  end
230
240
 
231
241
  # Allows manipulation of webhook health in context of the current client
@@ -233,8 +243,8 @@ module Contentful
233
243
  # @see _ README for details.
234
244
  #
235
245
  # @return [Contentful::Management::ClientWebhookHealthMethodsFactory]
236
- def webhook_health
237
- ClientWebhookHealthMethodsFactory.new(self)
246
+ def webhook_health(space_id)
247
+ ClientWebhookHealthMethodsFactory.new(self, space_id)
238
248
  end
239
249
 
240
250
  # Allows manipulation of uploads in context of the current client
@@ -242,8 +252,8 @@ module Contentful
242
252
  # @see _ README for details.
243
253
  #
244
254
  # @return [Contentful::Management::ClientUploadMethodsFactory]
245
- def uploads
246
- ClientUploadMethodsFactory.new(self)
255
+ def uploads(space_id)
256
+ ClientUploadMethodsFactory.new(self, space_id)
247
257
  end
248
258
 
249
259
  # Allows manipulation of snapshots in context of the current client
@@ -251,8 +261,8 @@ module Contentful
251
261
  # @see _ README for details.
252
262
  #
253
263
  # @return [Contentful::Management::ClientSnapshotMethodsFactory]
254
- def snapshots(resource_type = 'entries')
255
- ClientSnapshotMethodsFactory.new(self, resource_type)
264
+ def snapshots(space_id, environment_id, resource_type = 'entries')
265
+ ClientSnapshotMethodsFactory.new(self, space_id, environment_id, resource_type)
256
266
  end
257
267
 
258
268
  # Allows manipulation of entry snapshots in context of the current client
@@ -260,8 +270,8 @@ module Contentful
260
270
  # @see _ README for details.
261
271
  #
262
272
  # @return [Contentful::Management::ClientSnapshotMethodsFactory]
263
- def entry_snapshots
264
- ClientSnapshotMethodsFactory.new(self, 'entries')
273
+ def entry_snapshots(space_id, environment_id)
274
+ ClientSnapshotMethodsFactory.new(self, space_id, environment_id, 'entries')
265
275
  end
266
276
 
267
277
  # Allows manipulation of content type snapshots in context of the current client
@@ -269,8 +279,8 @@ module Contentful
269
279
  # @see _ README for details.
270
280
  #
271
281
  # @return [Contentful::Management::ClientSnapshotMethodsFactory]
272
- def content_type_snapshots
273
- ClientSnapshotMethodsFactory.new(self, 'content_types')
282
+ def content_type_snapshots(space_id, environment_id)
283
+ ClientSnapshotMethodsFactory.new(self, space_id, environment_id, 'content_types')
274
284
  end
275
285
 
276
286
  # @private
@@ -283,26 +293,29 @@ module Contentful
283
293
  def update_all_dynamic_entry_cache!
284
294
  return if configuration[:dynamic_entries].empty? || configuration[:disable_content_type_caching]
285
295
 
286
- spaces = configuration[:dynamic_entries].map { |space_id| ::Contentful::Management::Space.find(self, space_id) }
287
- update_dynamic_entry_cache_for_spaces!(spaces)
296
+ environments = configuration[:dynamic_entries].map do |space_id, environment_id|
297
+ ::Contentful::Management::Environment.find(self, space_id, environment_id)
298
+ end
299
+
300
+ update_dynamic_entry_cache_for_environments!(environments)
288
301
  end
289
302
 
290
303
  # @private
291
- def update_dynamic_entry_cache_for_spaces!(spaces)
304
+ def update_dynamic_entry_cache_for_environments!(environments)
292
305
  return if configuration[:disable_content_type_caching]
293
306
 
294
- spaces.each do |space|
295
- update_dynamic_entry_cache_for_space!(space)
307
+ environments.each do |environment|
308
+ update_dynamic_entry_cache_for_environment!(environment)
296
309
  end
297
310
  end
298
311
 
299
312
  # Use this method together with the client's :dynamic_entries configuration.
300
313
  # See README for details.
301
314
  # @private
302
- def update_dynamic_entry_cache_for_space!(space)
315
+ def update_dynamic_entry_cache_for_environment!(environment)
303
316
  return if configuration[:disable_content_type_caching]
304
317
 
305
- update_dynamic_entry_cache!(space.content_types.all)
318
+ update_dynamic_entry_cache!(environment.content_types.all)
306
319
  end
307
320
 
308
321
  # @private
@@ -10,6 +10,14 @@ module Contentful
10
10
  def new(*)
11
11
  fail 'Not supported'
12
12
  end
13
+
14
+ def find(resource_id)
15
+ associated_class.find(client, @space_id, resource_id)
16
+ end
17
+
18
+ def create(attributes)
19
+ associated_class.create(client, @space_id, attributes)
20
+ end
13
21
  end
14
22
  end
15
23
  end
@@ -1,5 +1,4 @@
1
1
  require_relative 'client_association_methods_factory'
2
- require_relative 'client_association_all_published_method_factory'
3
2
 
4
3
  module Contentful
5
4
  module Management
@@ -7,7 +6,6 @@ module Contentful
7
6
  # @private
8
7
  class ClientAssetMethodsFactory
9
8
  include Contentful::Management::ClientAssociationMethodsFactory
10
- include Contentful::Management::ClientAssociationAllPublishedMethodsFactory
11
9
  end
12
10
  end
13
11
  end
@@ -5,18 +5,17 @@ module Contentful
5
5
  module ClientAssociationAllPublishedMethodsFactory
6
6
  # Gets a collection of published resources.
7
7
  #
8
- # @param [String] space_id
9
8
  # @param [Hash] params
10
9
  # @see _ For complete option list: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters
11
10
  # @deprecated This call will be soon removed from the API except for Content Types
12
11
  #
13
12
  # @return [Contentful::Management::Array<Contentful::Management::Resource>]
14
- def all_published(space_id, params = {})
13
+ def all_published(params = {})
15
14
  warn('This call will soon be removed from the API except for Content Types') unless params.key?(:suppress_warning)
16
15
  params.delete(:suppress_warning) if params.key?(:suppress_warning)
17
16
 
18
17
  @resource_requester.all(
19
- { space_id: space_id, public: true },
18
+ { space_id: @space_id, environment_id: @environment_id, public: true },
20
19
  params
21
20
  )
22
21
  end
@@ -7,34 +7,34 @@ module Contentful
7
7
  module ClientAssociationMethodsFactory
8
8
  attr_reader :client
9
9
 
10
- def initialize(client)
10
+ def initialize(client, space_id = nil, environment_id = nil)
11
11
  @client = client
12
12
  @resource_requester = ResourceRequester.new(client, associated_class)
13
+ @space_id = space_id
14
+ @environment_id = environment_id
13
15
  end
14
16
 
15
17
  # Gets a collection of resources.
16
18
  #
17
- # @param [String] space_id
18
19
  # @param [Hash] params
19
20
  # @see _ For complete option list: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters
20
21
  #
21
22
  # @return [Contentful::Management::Array<Contentful::Management::Resource>]
22
- def all(space_id, params = {})
23
- associated_class.all(client, space_id, params)
23
+ def all(params = {})
24
+ associated_class.all(client, @space_id, @environment_id, params)
24
25
  end
25
26
 
26
27
  # Gets a specific resource.
27
28
  #
28
- # @param [String] space_id
29
29
  # @param [String] resource_id
30
30
  #
31
31
  # @return [Contentful::Management::Resource]
32
- def find(space_id, resource_id)
33
- associated_class.find(client, space_id, resource_id)
32
+ def find(resource_id)
33
+ associated_class.find(client, @space_id, @environment_id, resource_id)
34
34
  end
35
35
 
36
- def create(space_id, attributes)
37
- associated_class.create(client, space_id, attributes)
36
+ def create(attributes)
37
+ associated_class.create(client, @space_id, @environment_id, attributes)
38
38
  end
39
39
 
40
40
  def new
@@ -9,8 +9,14 @@ module Contentful
9
9
  include Contentful::Management::ClientAssociationMethodsFactory
10
10
  include Contentful::Management::ClientAssociationAllPublishedMethodsFactory
11
11
 
12
- def all_published(space_id, params = {})
13
- super(space_id, { suppress_warning: true }.merge(params))
12
+ def all(query = {})
13
+ content_types = super(query)
14
+ client.update_dynamic_entry_cache!(content_types)
15
+ content_types
16
+ end
17
+
18
+ def all_published(params = {})
19
+ super({ suppress_warning: true }.merge(params))
14
20
  end
15
21
  end
16
22
  end