module WoodWing::Elvis::Rest

Public Instance Methods

abort_checkout(options={})
Alias for: undo_checkout
browse(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-browse

browse folders and show their subfolders and collections, similar to how folder browsing works in the Elvis desktop client.

Note: Even though it is possible to return the assets in folders,

doing so is not advised. The browse call does not limit the
number of results, so if there are 10000 assets in a folder
it will return all of them. It is better to use a search to
find the assets in a folder and fetch them in pages.

yourserver.com/services/browse

?path=<assetPath>
&fromRoot=<folderPath>
&includeFolders=<true|false>
&includeAssets=<true|false>
&includeExtensions=<comma-delimited extensions>

Options

path    (Required) The path to the folder in Elvis you want to list.
        Make sure the URL is properly URL-encoded, for example: spaces should
        often be represented as %20.

fromRoot  Allows returning multiple levels of folders with their
          children. When specified, this path is listed, and all folders
          below it up to the 'path' will have their children returned as well.

          This ability can be used to initialize an initial path in a
          column tree folder browser with one server call.

          Optional. When not specified, only the children of the specified
          'path' will be returned.

          Available since Elvis 2.6

includeFolders  Indicates if folders should be returned.
                Optional. Default is true.

includeAsset  Indicates if files should be returned.
              Optional. Default is true, but filtered to
              only include 'container' assets.

includeExtensions   A comma separated list of file extensions to
                    be returned. Specify 'all' to return all file types.
                    Optional. Default includes all 'container'
                    assets: .collection, .dossier, .task
# File lib/woodwing/elvis/rest/browse.rb, line 53
def browse(options={})

  Utilities.demand_required_options!( :browse, options )

  url      = base_url + "browse"
  response = get_response(url, options)

end
checkout(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-checkout

# File lib/woodwing/elvis/rest/checkout.rb, line 7
def checkout(options={})
  url = base_url + "checkout"
  response = get_response(url, options)
end
create(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-create Upload and create an asset.

This call will create a new asset in Elvis. It can be used to upload files into Elvis. It can also be used to create 'virtual' assets like collections. In that case no file has to be uploaded and Elvis will create a 0 kb placeholder for the virtual asset.

When you want to create a new asset, certain metadata is required. The metadata is needed to determine where the file will be stored in Elvis.

yourserver.com/services/create

?Filedata=<multipart/form-data encoded file>
&metadata=<JSON encoded metadata>
&<Elvis metadata field name>=<value>
&nextUrl=<next URL>

Options

Filedata  The file to be created in Elvis.  If you do not specify a
          filename explicitly through the metadata, the filename of
          the uploaded file will be used.
          NOTE: The parameter is named "Filedata" because that is the
                standard name used by flash uploads. This makes it easy
                to use flash uploaders to upload batches of files to Elvis.
          Optional. If omitted, a 0kb placeholder file will be created.
          See the method create_collection()

metadata  A JSON encoded object with properties that match Elvis metadata
          field names. This metadata will be set on the asset in Elvis.
          Optional. You can also use parameters matching Elvis field names.

*   Any parameter matching an Elvis metadata field name will be used as
    metadata. This metadata will be set on the asset in Elvis.
    Optional. You also use the 'metadata' parameter.

nextUrl   When specified, the service will send a 301 redirect to this
          URL when it is completed successfully. If you place '${id}' in
          the URL, it will be replaced with the Elvis asset id of the
          created asset.
          Optional. If omitted, a simple 200 OK status code will be returned
# File lib/woodwing/elvis/rest/create.rb, line 48
def create(options={})

  Utilities.demand_required_options!( :create, options )

  # SMELL:  Don't think this is required since last change to
  #         get_response_with_post
  options.merge!( { multipart: true } )

  url       = base_url + "create"
  response  = get_response_using_post(url, options)

end
create_asset(options={})
Alias for: create
create_auth_key(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-createauthkey

# File lib/woodwing/elvis/rest/authorization_keys.rb, line 7
def create_auth_key(options={})
  url = base_url + "create_auth_key"
  response = get_response(url, options)
end
create_file(options={})
Alias for: create
create_folder(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-create_folder

# File lib/woodwing/elvis/rest/folders.rb, line 7
def create_folder(options={})
  Utilities.demand_required_options!( :create_folder, options )
  url = base_url + "createFolder"
  response = get_response(url, options)
end
create_relation(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-create_relation

# File lib/woodwing/elvis/rest/relations.rb, line 7
def create_relation(options={})
  url = base_url + "create_relation"
  response = get_response(url, options)
end
delete_folder(options={})
Alias for: remove_folder
delete_relation(options={})
Alias for: remove_relation
find(options={})
Alias for: search
import_asset(options={})
Alias for: create
import_file(options={})
Alias for: create
logged_in?() click to toggle source

A successful log in will result in a cookie

# File lib/woodwing/elvis/rest/login_logout.rb, line 11
def logged_in?
  not @cookies.empty?
end
login(options={}) click to toggle source

FIXME: Need to change Elvis to https otherwise anyone who snoops

the wire will find cred and be able to have complete access once
the white listed IP scheme has been dropped.
# File lib/woodwing/elvis/rest/login_logout.rb, line 158
def login(options={})

  raise AlreadyLoggedIn unless @cookies.empty?

  unless options.include?(:cred)
    options = {
      username:   ENV['ELVIS_USER'],
      password:   ENV['ELVIS_PASS']
      }.merge(options)
    options[:cred] = UrlSafeBase64.encode64("#{options[:username]}:#{options[:password]}")
  end

  options.delete(:username)
  options.delete(:password)

  options[:clientType]    = 'api_Ruby'
  options[:returnProfile] = 'true'

  url       = base_url + "login"
  response  = get_response(url, options)

  return response

end
Also aliased as: logon, signin
logoff(options={})
Alias for: logout
logon(options={})
Alias for: login
logout(options={}) click to toggle source
# https://elvis.tenderapp.com/kb/api/rest-logout

yourserver.com/services/logout

Terminates your browser session. Use this to end a session using an AJAX call.

Available since Elvis 2.6.

Parameters

This service has no parameters

Return value

# File lib/woodwing/elvis/rest/login_logout.rb, line 239
def logout(options={})

  url       = base_url + "logout"
  response  = get_response(url, options)

  @cookies  = {} if response[:logoutSuccess]

  return response

end
Also aliased as: signout, signoff, logoff
remove_folder(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-remove

# File lib/woodwing/elvis/rest/folders.rb, line 15
def remove_folder(options={})
  Utilities.demand_required_options!( :remove_folder, options )
  url = base_url + "remove"
  response = get_response(url, options)
end
Also aliased as: delete_folder
remove_relation(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-remove_relation

# File lib/woodwing/elvis/rest/relations.rb, line 14
def remove_relation(options={})
  url = base_url + "remove_relation"
  response = get_response(url, options)
end
Also aliased as: delete_relation
replace_auth_key(options={})
Alias for: update_auth_key
revoke_auth_keys(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-revokeauthkeys

# File lib/woodwing/elvis/rest/authorization_keys.rb, line 23
def revoke_auth_keys(options={})
  url = base_url + "revoke_auth_keys"
  response = get_response(url, options)
end
signin(options={})
Alias for: login
signoff(options={})
Alias for: logout
signout(options={})
Alias for: logout
stub() click to toggle source
# File lib/woodwing/elvis/rest/stub.rb, line 6
def stub(); end
undo_checkout(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-undo_checkout

# File lib/woodwing/elvis/rest/checkout.rb, line 14
def undo_checkout(options={})
  url = base_url + "undo_checkout"
  response = get_response(url, options)
end
Also aliased as: abort_checkout
update_auth_key(options={}) click to toggle source

elvis.tenderapp.com/kb/api/rest-update_auth_key

# File lib/woodwing/elvis/rest/authorization_keys.rb, line 14
def update_auth_key(options={})
  url = base_url + "update_auth_key"
  response = get_response(url, options)
end
Also aliased as: replace_auth_key
upload_asset(options={})
Alias for: create
upload_file(options={})
Alias for: create