Class: Mediaflux::NamespaceDescribeRequest

Inherits:
Request
  • Object
show all
Defined in:
app/models/mediaflux/namespace_describe_request.rb

Overview

Describes a namespace

Examples:

namespace = Mediaflux::NamespaceDescribeRequest.new(session_token: session_id).metadata
=> {:id=>"1", :path=>"/", :name=>"", :description=>"", :store=>"data"}
namespace = Mediaflux::NamespaceDescribeRequest.new(session_token: session_id, path: "/td-test-001/tigerdataNS").metadata
=> {:id=>"1182", :path=>"/td-test-001/tigerdataNS", :name=>"tigerdataNS", :description=>"TigerData client app root namespace", :store=>"db"}

Instance Attribute Summary collapse

Attributes inherited from Request

#session_token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

build_post_request, default_xml_namespace, default_xml_namespace_uri, #error?, find_or_create_http_client, format_date_for_mediaflux, request_path, #resolve, #resolved?, #response_body, #response_error, #response_xml, uri, #xml_payload, #xtoshell_xml

Constructor Details

#initialize(session_token:, path: nil, id: nil) ⇒ NamespaceDescribeRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session

  • path (String) (defaults to: nil)

    path of the asset to be described

  • id (Integer) (defaults to: nil)

    TODO: Define what this is and how to use it.



17
18
19
20
21
# File 'app/models/mediaflux/namespace_describe_request.rb', line 17

def initialize(session_token:, path: nil, id: nil)
  super(session_token: session_token)
  @path = path
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'app/models/mediaflux/namespace_describe_request.rb', line 11

def id
  @id
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'app/models/mediaflux/namespace_describe_request.rb', line 11

def path
  @path
end

Class Method Details

.serviceString

Specifies the Mediaflux service to use

Returns:

  • (String)


25
26
27
# File 'app/models/mediaflux/namespace_describe_request.rb', line 25

def self.service
  "asset.namespace.describe"
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/models/mediaflux/namespace_describe_request.rb', line 43

def exists?
  [:id].present?
end

#metadataObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/mediaflux/namespace_describe_request.rb', line 29

def 
  @metadata ||= begin
                  xml = response_xml
                  node = xml.xpath("/response/reply/result/namespace")
                  {
                    id: node.xpath("@id").text,
                    path: node.xpath("./path").text,
                    name: node.xpath("./name").text,
                    description: node.xpath("./description").text,
                    store: node.xpath("./store").text
                  }
                end
end