class GdsApi::AssetManager

@api documented

def asset(id)

Raises:
  • (HTTPErrorResponse) - if the request returns an error

Returns:
  • (GdsApi::Response, nil) - A response object containing the parsed JSON response. If

Parameters:
  • id (String) -- The asset identifier (a UUID).
def asset(id)
  get_json("#{base_url}/assets/#{id}")
end

def base_url

def base_url
  endpoint
end

def create_asset(asset)

Other tags:
    Example: Upload a file from a Rails param, (typically a multipart wrapper) -
    Example: Upload a file from disk -

Raises:
  • (HTTPErrorResponse) - if the request returns an error

Returns:
  • (GdsApi::Response) - The wrapped http response from the api. Behaves

Parameters:
  • asset (Hash) -- The attributes for the asset to send to the api. Must
def create_asset(asset)
  post_multipart("#{base_url}/assets", asset: asset)
end

def create_whitehall_asset(asset)

Other tags:
    Example: Upload a file from a Rails param, (typically a multipart wrapper) -
    Example: Upload a file from disk -

Raises:
  • (HTTPErrorResponse) - if the request returns an error

Returns:
  • (GdsApi::Response) - The wrapped http response from the api. Behaves

Parameters:
  • asset (Hash) -- The attributes for the asset to send to the api. Must
def create_whitehall_asset(asset)
  post_multipart("#{base_url}/whitehall_assets", asset: asset)
end

def delete_asset(id)

Other tags:
    Example: Delete a file from disk -

Raises:
  • (HTTPErrorResponse) - if the request returns an error

Returns:
  • (GdsApi::Response) - The wrapped http response from the api. Behaves

Parameters:
  • id (String) -- The asset identifier (a UUID).
def delete_asset(id)
  delete_json("#{base_url}/assets/#{id}")
end

def restore_asset(id)

Other tags:
    Example: Restore a deleted file -

Raises:
  • (HTTPErrorResponse) - if the request returns an error

Returns:
  • (GdsApi::Response) - The wrapped http response from the api. Behaves

Parameters:
  • id (String) -- The asset identifier (a UUID).
def restore_asset(id)
  post_json("#{base_url}/assets/#{id}/restore")
end

def update_asset(id, asset)

Other tags:
    Example: Update a file from disk -

Raises:
  • (HTTPErrorResponse) - if the request returns an error

Returns:
  • (GdsApi::Response) - The wrapped http response from the api. Behaves

Parameters:
  • asset (Hash) -- The attributes for the asset to send to the api. Must
  • id (String) -- The asset identifier (a UUID).
def update_asset(id, asset)
  put_multipart("#{base_url}/assets/#{id}", asset: asset)
end

def whitehall_asset(legacy_url_path)

Raises:
  • (HTTPErrorResponse) - if the request returns an error

Returns:
  • (GdsApi::Response) - A response object containing the parsed JSON

Parameters:
  • legacy_url_path (String) -- The Whitehall asset identifier.
def whitehall_asset(legacy_url_path)
  get_json("#{base_url}/whitehall_assets/#{Addressable::URI.encode(legacy_url_path)}")
end