gds-api-adapters 37.0.0 → 37.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80e428cbf9fbbf1cc956c99fdab6135b912b0eb7
4
- data.tar.gz: 2f3522bb16213e2fa76e8fad6786b65f1c4150f7
3
+ metadata.gz: 7cd9bfb40b63824da15fe31a714a66fd8512af2b
4
+ data.tar.gz: e5644d7072987cbd47d7075dd0efbc44655fe34b
5
5
  SHA512:
6
- metadata.gz: ba103489e0af11e87a3c3712043a27fd192e96f7242faa40b0e1e85a109337ea26e4ed08ed3ae1e3a474490c975063db7f91251e213d480c09fc14a1d1c959b5
7
- data.tar.gz: aa8e0fe34d8960d43bb68bd4facb7208459c64545be952414d945f0b35c2eaa20a38fb5376b0725efa422170ed442ccb3eefb8d1e21d745a7970c00c5d392747
6
+ metadata.gz: 8c713da493b564dd0314b4c966b9e83a54f35a36d9830634bcf1ebe6f7daa22012b6095a16dedf45f79fa6cb017cefe08c94d6e1c981187b24b4a7daf3d1ed9f
7
+ data.tar.gz: fd47cf2ce466072e5bf0221e1b1949589671c30972a718fd0285d68ce29e6f95046f79b74b1e30c0f5ff360a42a18672ce9624cda5d6a519a4326790fb26d094
@@ -114,6 +114,29 @@ class GdsApi::AssetManager < GdsApi::Base
114
114
  delete_json("#{base_url}/assets/#{id}")
115
115
  end
116
116
 
117
+ # Restores an asset given an id
118
+ #
119
+ # Makes a +POST+ request to the asset manager api to restore an asset.
120
+ #
121
+ # @param id [String] The asset identifier (a UUID).
122
+ # @return [GdsApi::Response] The wrapped http response from the api. Behaves
123
+ # both as a +Hash+ and an +OpenStruct+, and responds to the following:
124
+ # :id the URL of the asset
125
+ # :name the filename of the asset that will be served
126
+ # :content_type the content_type of the asset
127
+ # :file_url the URL from which the asset will be served when it has
128
+ # passed a virus scan
129
+ # :state One of 'unscanned', 'clean', or 'infected'. Unless the state is
130
+ # 'clean' the asset at the :file_url will 404
131
+ #
132
+ # @raise [HTTPErrorResponse] if the request returns an error
133
+ # @example Restore a deleted file
134
+ # uuid = '594602dd-75b3-4e6f-b5d1-cacf8c4d4164'
135
+ # asset_manager.restore_asset(uuid)
136
+ def restore_asset(id)
137
+ post_json("#{base_url}/assets/#{id}/restore")
138
+ end
139
+
117
140
  private
118
141
  def base_url
119
142
  endpoint
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '37.0.0'.freeze
2
+ VERSION = '37.1.0'.freeze
3
3
  end
@@ -81,4 +81,14 @@ describe GdsApi::AssetManager do
81
81
  assert_equal "#{base_api_url}/assets/#{asset_id}", response['asset']['id']
82
82
  assert_requested(req)
83
83
  end
84
+
85
+ it "restores an asset for the given id" do
86
+ req = stub_request(:post, "#{base_api_url}/assets/#{asset_id}/restore").
87
+ to_return(body: JSON.dump(asset_manager_response), status: 200)
88
+
89
+ response = api.restore_asset(asset_id)
90
+
91
+ assert_equal "#{base_api_url}/assets/#{asset_id}", response['asset']['id']
92
+ assert_requested(req)
93
+ end
84
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 37.0.0
4
+ version: 37.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-04 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek