Class: Viewpoint::SPWSClient

Inherits:
Object
  • Object
show all
Includes:
SPWS
Defined in:
lib/viewpoint/spws/spws_client.rb

Overview

This class is the glue between the Models and the Web Service.

Constant Summary collapse

LIST_TYPES =

Available list types that can be used for #add_list

{
  :custom_list      => 100,
  :document_library => 101,
  :survey           => 102,
  :links            => 103,
  :announcements    => 104,
  :contacts         => 105,
  :events           => 106,
  :tasks            => 107,
  :discussion_board => 108,
  :picture_library  => 109,
  :datasources      => 110,
  :form_library     => 115,
  :issues           => 1100,
  :custom_list_for_datasheet => 120,
}

Constants included from SPWS

Viewpoint::SPWS::VERSION

Instance Attribute Summary

Attributes included from SPWS

#logger

Instance Method Summary collapse

Methods included from SPWS

root_logger, set_log_level

Constructor Details

#initialize(endpoint, user = nil, pass = nil) ⇒ SPWSClient

Initialize the SPWSClient instance.

Parameters:

  • endpoint (String)

    The SPWS endpoint we will be connecting to

  • user (String) (defaults to: nil)

    The user to authenticate as. If you are using NTLM or Negotiate authentication you do not need to pass this parameter.

  • pass (String) (defaults to: nil)

    The user password. If you are using NTLM or Negotiate authentication you do not need to pass this parameter.



29
30
31
32
# File 'lib/viewpoint/spws/spws_client.rb', line 29

def initialize(endpoint, user = nil, pass = nil)
  @con = Connection.new(endpoint)
  @con.set_auth(user,pass) if(user && pass)
end

Instance Method Details

#add_list(name, desc, list_type) ⇒ Object

Add a List to this site

Parameters:

  • name (String)

    A name for the List

  • desc (String)

    A description of the List

  • list_type (Integer)

    The list template id. Use the LIST_TYPES Hash.



82
83
84
# File 'lib/viewpoint/spws/spws_client.rb', line 82

def add_list(name, desc, list_type)
  lists_ws.add_list(name, desc, list_type)
end

#copy_wsObject



34
35
36
# File 'lib/viewpoint/spws/spws_client.rb', line 34

def copy_ws
  @copyws ||= Websvc::Copy.new(@con)
end

#delete_list(list) ⇒ Object

Delete a list from this site.

Parameters:

  • list (String)

    title or the GUID for the list



88
89
90
# File 'lib/viewpoint/spws/spws_client.rb', line 88

def delete_list(list)
  lists_ws.delete_list(list)
end

#get_list(list) ⇒ Object

Retrieve a List object

Parameters:

  • list (String)

    title or the GUID for the list



74
75
76
# File 'lib/viewpoint/spws/spws_client.rb', line 74

def get_list(list)
  lists_ws.get_list(list)
end

#get_listsObject

Retrieve all of the viewable lists for this site.



68
69
70
# File 'lib/viewpoint/spws/spws_client.rb', line 68

def get_lists
  lists_ws.get_list_collection
end

#get_user(user) ⇒ Viewpoint::SPWS::Types::User

Retrieve a user by e-mail

Parameters:

  • user (String)

    either in e-mail form or DOMAINlogin form. If you specify an e-mail there is an additional web service call that needs to be made so if you’re worried about performance use the DOMAINlogin form.

Returns:



100
101
102
103
104
105
106
# File 'lib/viewpoint/spws/spws_client.rb', line 100

def get_user(user)
  if user =~ /@/
    ulh = usergroup_ws. [user]
    user = ulh[user]
  end
  usergroup_ws. user
end

#lists_wsObject



38
39
40
# File 'lib/viewpoint/spws/spws_client.rb', line 38

def lists_ws
  @listsws ||= Websvc::Lists.new(@con)
end

#usergroup_wsObject



42
43
44
# File 'lib/viewpoint/spws/spws_client.rb', line 42

def usergroup_ws
  @usergroupws ||= Websvc::UserGroup.new(@con)
end