Class: Mediaflux::NamespaceDestroyRequest

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

Overview

Destroy a MediaFlux namespace and everything in it

Examples:

Mediaflux::NamespaceDestroyRequest.new(session_token: session_id, namespace: "/td-test-001/tigerdataNS/Banana1NS").destroy
=> true

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:, namespace:, ignore_missing: false) ⇒ NamespaceDestroyRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session

  • namespace (String)

    name of namespace to be destroyed

  • ignore_missing (Bool) (defaults to: false)

    ignore error if the namespace to delete is missing



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

def initialize(session_token:, namespace:, ignore_missing: false)
  super(session_token: session_token)
  @namespace = namespace
  @ignore_missing = ignore_missing
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



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

def namespace
  @namespace
end

#storeObject (readonly)

Returns the value of attribute store.



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

def store
  @store
end

Class Method Details

.serviceString

Specifies the Mediaflux service to use when destroying namespaces

Returns:

  • (String)


33
34
35
# File 'app/models/mediaflux/namespace_destroy_request.rb', line 33

def self.service
  "asset.namespace.hard.destroy"
end

Instance Method Details

#destroyObject



20
21
22
23
24
25
26
27
28
29
# File 'app/models/mediaflux/namespace_destroy_request.rb', line 20

def destroy
  resolve
  if error?
    if response_error.fetch(:message, "").include?("does not exist or is not accessible") && @ignore_missing
      # nothing to do
    else
      raise(StandardError, "call to service 'asset.namespace.hard.destroy' failed: The namespace #{namespace} does not exist or is not accessible")
    end
  end
end