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,6 +1,6 @@
1
- require_relative 'resource/system_properties'
2
- require_relative 'resource/refresher'
3
1
  require 'date'
2
+ require_relative 'resource/refresher'
3
+ require_relative 'resource/system_properties'
4
4
 
5
5
  module Contentful
6
6
  module Management
@@ -65,7 +65,11 @@ module Contentful
65
65
  def update(attributes)
66
66
  ResourceRequester.new(client, self.class).update(
67
67
  self,
68
- { space_id: space.id, resource_id: id },
68
+ {
69
+ space_id: space.id,
70
+ environment_id: environment_id,
71
+ resource_id: id
72
+ },
69
73
  query_attributes(attributes),
70
74
  version: sys[:version]
71
75
  )
@@ -75,7 +79,11 @@ module Contentful
75
79
  #
76
80
  # @return [true, Contentful::Management::Error] success
77
81
  def destroy
78
- ResourceRequester.new(client, self.class).destroy(space_id: space.id, resource_id: id)
82
+ ResourceRequester.new(client, self.class).destroy(
83
+ space_id: space.id,
84
+ environment_id: environment_id,
85
+ resource_id: id
86
+ )
79
87
  end
80
88
 
81
89
  # @private
@@ -116,6 +124,11 @@ module Contentful
116
124
  true
117
125
  end
118
126
 
127
+ # Returns the Environment ID
128
+ def environment_id
129
+ nil
130
+ end
131
+
119
132
  protected
120
133
 
121
134
  def query_attributes(attributes)
@@ -168,9 +181,16 @@ module Contentful
168
181
 
169
182
  # @private
170
183
  def build_endpoint(endpoint_options)
171
- return "spaces/#{endpoint_options[:space_id]}/public/#{endpoint}" if endpoint_options.key?(:public)
172
- base = "spaces/#{endpoint_options[:space_id]}/#{endpoint}"
173
- return "#{base}/#{endpoint_options[:resource_id]}#{endpoint_options[:suffix]}" if endpoint_options.key?(:resource_id)
184
+ if endpoint_options.key?(:public)
185
+ base = "spaces/#{endpoint_options[:space_id]}"
186
+ base = "#{base}/environments/#{endpoint_options[:environment_id]}" if endpoint_options[:environment_id]
187
+ return "#{base}/public/#{endpoint}"
188
+ end
189
+
190
+ base = "spaces/#{endpoint_options[:space_id]}"
191
+ base = "#{base}/environments/#{endpoint_options[:environment_id]}" if endpoint_options[:environment_id]
192
+ base = "#{base}/#{endpoint}"
193
+ return "#{base}/#{endpoint_options[:resource_id]}#{endpoint_options[:suffix]}" if endpoint_options[:resource_id]
174
194
  base
175
195
  end
176
196
 
@@ -182,8 +202,8 @@ module Contentful
182
202
  # @see _ For complete option list: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters
183
203
  #
184
204
  # @return [Contentful::Management::Array<Contentful::Management::Resource>]
185
- def all(client, space_id, parameters = {})
186
- ResourceRequester.new(client, self).all({ space_id: space_id }, parameters)
205
+ def all(client, space_id, environment_id = nil, parameters = {})
206
+ ResourceRequester.new(client, self).all({ space_id: space_id, environment_id: environment_id }, parameters)
187
207
  end
188
208
 
189
209
  # Gets a specific resource.
@@ -193,20 +213,21 @@ module Contentful
193
213
  # @param [String] resource_id
194
214
  #
195
215
  # @return [Contentful::Management::Resource]
196
- def find(client, space_id, resource_id)
197
- ResourceRequester.new(client, self).find(space_id: space_id, resource_id: resource_id)
216
+ def find(client, space_id, environment_id = nil, resource_id = nil)
217
+ ResourceRequester.new(client, self).find(space_id: space_id, environment_id: environment_id, resource_id: resource_id)
198
218
  end
199
219
 
200
220
  # Creates a resource.
201
221
  #
202
222
  # @param [Contentful::Management::Client] client
203
223
  # @param [String] space_id
224
+ # @param [String] environment_id
204
225
  # @param [Hash] attributes
205
226
  # @see _ README for full attribute list for each resource.
206
227
  #
207
228
  # @return [Contentful::Management::Resource]
208
- def create(client, space_id, attributes)
209
- endpoint_options = { space_id: space_id }
229
+ def create(client, space_id, environment_id = nil, attributes = {})
230
+ endpoint_options = { space_id: space_id, environment_id: environment_id }
210
231
  endpoint_options[:resource_id] = attributes[:id] if attributes.respond_to?(:key) && attributes.key?(:id)
211
232
  ResourceRequester.new(client, self).create(
212
233
  endpoint_options,
@@ -16,8 +16,8 @@ module Contentful
16
16
  # @deprecated This call will be soon removed from the API except for Content Types
17
17
  #
18
18
  # @return [Contentful::Management::Array<Contentful::Management::Resource>]
19
- def all_published(client, space_id, parameters = {})
20
- client_association_class.new(client).all_published(space_id, parameters)
19
+ def all_published(client, space_id, environment_id, parameters = {})
20
+ client_association_class.new(client, space_id, environment_id).all_published(parameters)
21
21
  end
22
22
  end
23
23
  end
@@ -9,7 +9,12 @@ module Contentful
9
9
  def archive
10
10
  ResourceRequester.new(client, self.class).archive(
11
11
  self,
12
- { space_id: space.id, resource_id: id, suffix: '/archived' },
12
+ {
13
+ space_id: space.id,
14
+ environment_id: environment_id,
15
+ resource_id: id,
16
+ suffix: '/archived'
17
+ },
13
18
  version: sys[:version]
14
19
  )
15
20
  end
@@ -20,7 +25,12 @@ module Contentful
20
25
  def unarchive
21
26
  ResourceRequester.new(client, self.class).unarchive(
22
27
  self,
23
- { space_id: space.id, resource_id: id, suffix: '/archived' },
28
+ {
29
+ space_id: space.id,
30
+ environment_id: environment_id,
31
+ resource_id: id,
32
+ suffix: '/archived'
33
+ },
24
34
  version: sys[:version]
25
35
  )
26
36
  end
@@ -0,0 +1,13 @@
1
+ module Contentful
2
+ module Management
3
+ module Resource
4
+ # Mixin for environment aware resources
5
+ module EnvironmentAware
6
+ # Gets the environment ID for the resource.
7
+ def environment_id
8
+ sys.fetch(:environment, {}).fetch(:id, 'master')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -9,7 +9,12 @@ module Contentful
9
9
  def publish
10
10
  ResourceRequester.new(client, self.class).publish(
11
11
  self,
12
- { space_id: space.id, resource_id: id, suffix: '/published' },
12
+ {
13
+ space_id: space.id,
14
+ environment_id: environment_id,
15
+ resource_id: id,
16
+ suffix: '/published'
17
+ },
13
18
  version: sys[:version]
14
19
  )
15
20
  end
@@ -20,7 +25,12 @@ module Contentful
20
25
  def unpublish
21
26
  ResourceRequester.new(client, self.class).unpublish(
22
27
  self,
23
- { space_id: space.id, resource_id: id, suffix: '/published' },
28
+ {
29
+ space_id: space.id,
30
+ environment_id: environment_id,
31
+ resource_id: id,
32
+ suffix: '/published'
33
+ },
24
34
  version: sys[:version]
25
35
  )
26
36
  end
@@ -12,7 +12,7 @@ module Contentful
12
12
 
13
13
  # @private
14
14
  def refresh_find
15
- self.class.find(client, space.id, id)
15
+ self.class.find(client, space.id, environment_id, id)
16
16
  end
17
17
 
18
18
  # @private
@@ -1,26 +1,27 @@
1
+ require_relative 'link'
2
+ require_relative 'user'
3
+ require_relative 'role'
1
4
  require_relative 'error'
2
- require_relative 'resource'
3
5
  require_relative 'entry'
4
- require_relative 'dynamic_entry'
5
6
  require_relative 'array'
6
- require_relative 'link'
7
7
  require_relative 'space'
8
- require_relative 'space_membership'
9
- require_relative 'organization'
10
- require_relative 'user'
11
- require_relative 'content_type'
12
8
  require_relative 'asset'
9
+ require_relative 'locale'
10
+ require_relative 'upload'
13
11
  require_relative 'webhook'
14
- require_relative 'webhook_call'
15
- require_relative 'webhook_health'
16
12
  require_relative 'api_key'
17
- require_relative 'personal_access_token'
18
- require_relative 'locale'
19
- require_relative 'role'
13
+ require_relative 'resource'
14
+ require_relative 'snapshot'
15
+ require_relative 'environment'
16
+ require_relative 'organization'
17
+ require_relative 'content_type'
18
+ require_relative 'webhook_call'
20
19
  require_relative 'ui_extension'
20
+ require_relative 'dynamic_entry'
21
+ require_relative 'webhook_health'
22
+ require_relative 'space_membership'
21
23
  require_relative 'editor_interface'
22
- require_relative 'snapshot'
23
- require_relative 'upload'
24
+ require_relative 'personal_access_token'
24
25
 
25
26
  module Contentful
26
27
  module Management
@@ -34,6 +35,7 @@ module Contentful
34
35
  'SpaceMembership' => Contentful::Management::SpaceMembership,
35
36
  'Organization' => Contentful::Management::Organization,
36
37
  'User' => Contentful::Management::User,
38
+ 'Environment' => Contentful::Management::Environment,
37
39
  'ContentType' => Contentful::Management::ContentType,
38
40
  'Entry' => :find_entry_class,
39
41
  'Asset' => Contentful::Management::Asset,
@@ -1,5 +1,5 @@
1
- require_relative 'error'
2
1
  require 'multi_json'
2
+ require_relative 'error'
3
3
 
4
4
  module Contentful
5
5
  module Management
@@ -5,13 +5,13 @@ module Contentful
5
5
  # Resource class for Role.
6
6
  class Role
7
7
  include Contentful::Management::Resource
8
- include Contentful::Management::Resource::SystemProperties
9
8
  include Contentful::Management::Resource::Refresher
9
+ include Contentful::Management::Resource::SystemProperties
10
10
 
11
11
  property :name, :string
12
+ property :policies, :array
12
13
  property :description, :string
13
14
  property :permissions, :hash
14
- property :policies, :array
15
15
 
16
16
  # @private
17
17
  def self.create_attributes(_client, attributes)
@@ -23,11 +23,38 @@ module Contentful
23
23
  }
24
24
  end
25
25
 
26
+ # Creates a role.
27
+ #
28
+ # @param [Contentful::Management::Client] client
29
+ # @param [String] space_id
30
+ # @param [Hash] attributes
31
+ #
32
+ # @return [Contentful::Management::Role]
33
+ def self.create(client, space_id, attributes = {})
34
+ super(client, space_id, nil, attributes)
35
+ end
36
+
37
+ # Finds a role by ID.
38
+ #
39
+ # @param [Contentful::Management::Client] client
40
+ # @param [String] space_id
41
+ # @param [String] role_id
42
+ #
43
+ # @return [Contentful::Management::Role]
44
+ def self.find(client, space_id, role_id)
45
+ super(client, space_id, nil, role_id)
46
+ end
47
+
26
48
  protected
27
49
 
28
50
  def query_attributes(attributes)
29
51
  attributes.each_with_object({}) { |(k, v), result| result[k.to_sym] = v }
30
52
  end
53
+
54
+ # @private
55
+ def refresh_find
56
+ self.class.find(client, space.id, id)
57
+ end
31
58
  end
32
59
  end
33
60
  end
@@ -1,4 +1,5 @@
1
1
  require_relative 'resource'
2
+ require_relative 'resource/environment_aware'
2
3
  require_relative 'client_snapshot_methods_factory'
3
4
 
4
5
  module Contentful
@@ -7,8 +8,9 @@ module Contentful
7
8
  # @see _ https://www.contentful.com/developers/docs/references/content-management-api/#/reference/snapshots
8
9
  class Snapshot
9
10
  include Contentful::Management::Resource
10
- include Contentful::Management::Resource::SystemProperties
11
11
  include Contentful::Management::Resource::Refresher
12
+ include Contentful::Management::Resource::SystemProperties
13
+ include Contentful::Management::Resource::EnvironmentAware
12
14
 
13
15
  # @private
14
16
  def self.property_coercions
@@ -30,25 +32,28 @@ module Contentful
30
32
  #
31
33
  # @param [Contentful::Management::Client] client
32
34
  # @param [String] space_id
35
+ # @param [String] environment_id
33
36
  # @param [String] resource_id
34
37
  # @param [String] resource_type
35
38
  #
36
39
  # @return [Contentful::Management::Array<Contentful::Management::Snapshot>]
37
- def self.all(client, space_id, resource_id, resource_type = 'entries', params = {})
38
- ClientSnapshotMethodsFactory.new(client, resource_type).all(space_id, resource_id, params)
40
+ # rubocop:disable Metrics/ParameterLists
41
+ def self.all(client, space_id, environment_id, resource_id, resource_type = 'entries', params = {})
42
+ ClientSnapshotMethodsFactory.new(client, space_id, environment_id, resource_type).all(resource_id, params)
39
43
  end
40
44
 
41
45
  # Gets a snapshot by ID
42
46
  #
43
47
  # @param [Contentful::Management::Client] client
44
48
  # @param [String] space_id
49
+ # @param [String] environment_id
45
50
  # @param [String] resource_id
46
51
  # @param [String] snapshot_id
47
52
  # @param [String] resource_type
48
53
  #
49
54
  # @return [Contentful::Management::Snapshot]
50
- def self.find(client, space_id, resource_id, snapshot_id, resource_type = 'entries')
51
- ClientSnapshotMethodsFactory.new(client, resource_type).find(space_id, resource_id, snapshot_id)
55
+ def self.find(client, space_id, environment_id, resource_id, snapshot_id, resource_type = 'entries')
56
+ ClientSnapshotMethodsFactory.new(client, space_id, environment_id, resource_type).find(resource_id, snapshot_id)
52
57
  end
53
58
 
54
59
  # Not supported
@@ -65,11 +70,12 @@ module Contentful
65
70
  def self.build_endpoint(endpoint_options)
66
71
  resource_type = endpoint_options.fetch(:resource_type, 'entries')
67
72
  space_id = endpoint_options.fetch(:space_id)
73
+ environment_id = endpoint_options.fetch(:environment_id)
68
74
  resource_id = endpoint_options.fetch(:resource_id)
69
75
  snapshot_id = endpoint_options.fetch(:snapshot_id, nil)
70
76
 
71
- endpoint = "spaces/#{space_id}/#{resource_type}/#{resource_id}/snapshots"
72
- endpoint = "#{endpoint}/#{snapshot_id}" unless snapshot_id.nil?
77
+ endpoint = "spaces/#{space_id}/environments/#{environment_id}/#{resource_type}/#{resource_id}/snapshots"
78
+ endpoint = "#{endpoint}/#{snapshot_id}" if snapshot_id
73
79
 
74
80
  endpoint
75
81
  end
@@ -1,24 +1,15 @@
1
- require_relative 'resource'
2
- require_relative 'space_membership'
3
- require_relative 'space_space_membership_methods_factory'
1
+ require_relative 'role'
4
2
  require_relative 'locale'
5
- require_relative 'space_locale_methods_factory'
6
- require_relative 'content_type'
7
- require_relative 'space_content_type_methods_factory'
8
- require_relative 'asset'
9
- require_relative 'space_asset_methods_factory'
10
- require_relative 'entry'
11
- require_relative 'space_entry_methods_factory'
3
+ require_relative 'api_key'
12
4
  require_relative 'webhook'
13
- require_relative 'space_webhook_methods_factory'
14
- require_relative 'role'
5
+ require_relative 'resource'
6
+ require_relative 'environment'
7
+ require_relative 'space_membership'
15
8
  require_relative 'space_role_methods_factory'
16
- require_relative 'ui_extension'
17
- require_relative 'space_ui_extension_methods_factory'
18
- require_relative 'editor_interface'
19
- require_relative 'space_editor_interface_methods_factory'
20
- require_relative 'api_key'
9
+ require_relative 'space_webhook_methods_factory'
21
10
  require_relative 'space_api_key_methods_factory'
11
+ require_relative 'space_environment_methods_factory'
12
+ require_relative 'space_space_membership_methods_factory'
22
13
 
23
14
  module Contentful
24
15
  module Management
@@ -26,14 +17,11 @@ module Contentful
26
17
  # @see _ https://www.contentful.com/developers/documentation/content-management-api/#resources-spaces
27
18
  class Space
28
19
  include Contentful::Management::Resource
29
- include Contentful::Management::Resource::SystemProperties
30
20
  include Contentful::Management::Resource::Refresher
21
+ include Contentful::Management::Resource::SystemProperties
31
22
 
32
23
  property :name, :string
33
24
  property :organization, :string
34
- property :locales, Locale
35
-
36
- attr_accessor :found_locale
37
25
 
38
26
  # @private
39
27
  def self.build_endpoint(endpoint_options)
@@ -71,11 +59,6 @@ module Contentful
71
59
  { organization_id: attributes[:organization_id] }
72
60
  end
73
61
 
74
- # @private
75
- def after_create(attributes)
76
- self.found_locale = attributes[:default_locale] || client.default_locale
77
- end
78
-
79
62
  # Create a space.
80
63
  #
81
64
  # @param [Contentful::Management::Client] client
@@ -126,13 +109,13 @@ module Contentful
126
109
  ResourceRequester.new(client, self.class).destroy(space_id: id)
127
110
  end
128
111
 
129
- # Allows manipulation of content types in context of the current space
130
- # Allows listing all content types of space, creating new and finding one by ID.
112
+ # Allows manipulation of environments in context of the current space
113
+ # Allows listing all environments of space, creating new and finding one by ID.
131
114
  # @see _ README for details.
132
115
  #
133
- # @return [Contentful::Management::SpaceContentTypeMethodsFactory]
134
- def content_types
135
- SpaceContentTypeMethodsFactory.new(self)
116
+ # @return [Contentful::Management::SpaceEnvironmentMethodsFactory]
117
+ def environments
118
+ SpaceEnvironmentMethodsFactory.new(self)
136
119
  end
137
120
 
138
121
  # Allows manipulation of api keys in context of the current space
@@ -144,15 +127,6 @@ module Contentful
144
127
  SpaceApiKeyMethodsFactory.new(self)
145
128
  end
146
129
 
147
- # Allows manipulation of locales in context of the current space
148
- # Allows listing all locales of space, creating new and finding one by ID.
149
- # @see _ README for details.
150
- #
151
- # @return [Contentful::Management::SpaceLocaleMethodsFactory]
152
- def locales
153
- SpaceLocaleMethodsFactory.new(self)
154
- end
155
-
156
130
  # Allows manipulation of space memberships in context of the current space
157
131
  # Allows listing all space memberships of space, creating new and finding one by ID.
158
132
  # @see _ README for details.
@@ -171,42 +145,6 @@ module Contentful
171
145
  SpaceRoleMethodsFactory.new(self)
172
146
  end
173
147
 
174
- # Allows manipulation of UI extension in context of the current space
175
- # Allows listing all UI extension of space, creating new and finding one by ID.
176
- # @see _ README for details.
177
- #
178
- # @return [Contentful::Management::SpaceUIExtensionMethodsFactory]
179
- def ui_extensions
180
- SpaceUIExtensionMethodsFactory.new(self)
181
- end
182
-
183
- # Allows manipulation of editor interfaces in context of the current space
184
- # Allows listing all editor interfaces of space, creating new and finding one by ID.
185
- # @see _ README for details.
186
- #
187
- # @return [Contentful::Management::SpaceEditorInterfaceMethodsFactory]
188
- def editor_interfaces
189
- SpaceEditorInterfaceMethodsFactory.new(self)
190
- end
191
-
192
- # Allows manipulation of assets in context of the current space
193
- # Allows listing all assets of space, creating new and finding one by ID.
194
- # @see _ README for details.
195
- #
196
- # @return [Contentful::Management::SpaceAssetMethodsFactory]
197
- def assets
198
- SpaceAssetMethodsFactory.new(self)
199
- end
200
-
201
- # Allows manipulation of entries in context of the current space
202
- # Allows listing all entries for space and finding one by ID.
203
- # @see _ README for details.
204
- #
205
- # @return [Contentful::Management::SpaceEntryMethodsFactory]
206
- def entries
207
- SpaceEntryMethodsFactory.new(self)
208
- end
209
-
210
148
  # Allows manipulation of webhooks in context of the current space
211
149
  # Allows listing all webhooks for space and finding one by ID.
212
150
  # @see _ README for details.
@@ -216,23 +154,6 @@ module Contentful
216
154
  SpaceWebhookMethodsFactory.new(self)
217
155
  end
218
156
 
219
- # Retrieves Default Locale for current Space and leaves it cached
220
- #
221
- # @return [String]
222
- def default_locale
223
- self.found_locale ||= find_locale
224
- end
225
-
226
- # Finds Default Locale Code for current Space
227
- # This request makes an API call to the Locale endpoint
228
- #
229
- # @return [String]
230
- def find_locale
231
- locale = locales.all.detect(&:default)
232
- return locale.code unless locale.nil?
233
- @default_locale
234
- end
235
-
236
157
  protected
237
158
 
238
159
  def refresh_find