Class: Mediaflux::NamespaceListRequest

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

Overview

List all of the namespaces that are inside of a given namespace

Examples:

namespace_list = Mediaflux::NamespaceListRequest.new(session_token: session_id, parent_namespace: "/td-test-001/tigerdataNS").namespaces
=> [{:id=>"1264", :name=>"Avocado1NS"}, {:id=>"1282", :name=>"Banana1NS"}]

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:, parent_namespace:) ⇒ NamespaceListRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session, same as session_id

  • parent_namespace (String)

    Parent namespace for the query



13
14
15
16
# File 'app/models/mediaflux/namespace_list_request.rb', line 13

def initialize(session_token:, parent_namespace:)
  super(session_token: session_token)
  @parent_namespace = parent_namespace
end

Instance Attribute Details

#parent_namespaceObject (readonly)

Returns the value of attribute parent_namespace.



8
9
10
# File 'app/models/mediaflux/namespace_list_request.rb', line 8

def parent_namespace
  @parent_namespace
end

Class Method Details

.serviceString

Specifies the Mediaflux service to use when creating assets

Returns:

  • (String)


20
21
22
# File 'app/models/mediaflux/namespace_list_request.rb', line 20

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

Instance Method Details

#namespacesObject



24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/mediaflux/namespace_list_request.rb', line 24

def namespaces
  @namespaces ||= begin
                    xml = response_xml
                    namespaces = []
                    xml.xpath("/response/reply/result/namespace/namespace").each.each do |ns|
                      id = ns.xpath("@id").text
                      namespaces << { id: id, name: ns.text }
                    end
                    namespaces
                  end
end