Class: Mediaflux::QueryRequest

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

Direct Known Subclasses

CollectionQueryRequest

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:, aql_query: nil, collection: nil, action: "get-values", deep_search: false) ⇒ QueryRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session

  • aql_query (String) (defaults to: nil)

    Optional AQL query string

  • collection (Integer) (defaults to: nil)

    Optional collection id

  • action (String) (defaults to: "get-values")

    Optional, by default it uses get-name but it could also be get-meta to get all the fields for the assets or ‘get-values` to get a limited list of fields.

  • deep_search (Bool) (defaults to: false)

    Optional, false by default. When true queries the collection and it subcollections.



13
14
15
16
17
18
19
# File 'app/models/mediaflux/query_request.rb', line 13

def initialize(session_token:, aql_query: nil, collection: nil, action: "get-values", deep_search: false)
  super(session_token: session_token)
  @aql_query = aql_query
  @collection = collection
  @action = action
  @deep_search = deep_search
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



4
5
6
# File 'app/models/mediaflux/query_request.rb', line 4

def action
  @action
end

#aql_queryObject (readonly)

Returns the value of attribute aql_query.



4
5
6
# File 'app/models/mediaflux/query_request.rb', line 4

def aql_query
  @aql_query
end

#collectionObject (readonly)

Returns the value of attribute collection.



4
5
6
# File 'app/models/mediaflux/query_request.rb', line 4

def collection
  @collection
end

#deep_searchObject (readonly)

Returns the value of attribute deep_search.



4
5
6
# File 'app/models/mediaflux/query_request.rb', line 4

def deep_search
  @deep_search
end

Class Method Details

.serviceString

Specifies the Mediaflux service to use when running a query

Returns:

  • (String)


23
24
25
# File 'app/models/mediaflux/query_request.rb', line 23

def self.service
  "asset.query"
end

Instance Method Details

#resultObject

Returns the iterator that could be used to fetch the data



28
29
30
31
# File 'app/models/mediaflux/query_request.rb', line 28

def result
  xml = response_xml
  xml.xpath("/response/reply/result/iterator").text.to_i
end