postini 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/PostInstall.txt +5 -4
- data/config/hoe.rb +1 -1
- data/lib/postini/domain.rb +10 -3
- data/lib/postini/user.rb +13 -6
- data/lib/postini/version.rb +1 -1
- data/lib/postini.rb +74 -32
- data/website/index.html +1 -1
- metadata +17 -6
data/History.txt
CHANGED
data/PostInstall.txt
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
|
2
|
-
For more information on postini4r, see
|
3
|
-
|
4
|
-
NOTE: Change this information in PostInstall.txt
|
5
|
-
You can also delete it if you don't want it.
|
2
|
+
For more information on postini4r's postini gem, see
|
3
|
+
http://postini4r.rubyforge.org/postini
|
6
4
|
|
5
|
+
Remember to contact your Postini provider, or Postini directly, to gain access
|
6
|
+
to the Postini Early Access Program. You'll need a unique API key to make use
|
7
|
+
of this gem.
|
7
8
|
|
data/config/hoe.rb
CHANGED
@@ -64,7 +64,7 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
64
64
|
|
65
65
|
# == Optional
|
66
66
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
67
|
-
|
67
|
+
p.extra_deps = EXTRA_DEPENDENCIES
|
68
68
|
|
69
69
|
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
70
70
|
end
|
data/lib/postini/domain.rb
CHANGED
@@ -13,7 +13,7 @@ module Postini
|
|
13
13
|
|
14
14
|
# Return an instance of #Domain with all the attributes populated
|
15
15
|
def find( domain )
|
16
|
-
remote =
|
16
|
+
remote = automated_batch_port
|
17
17
|
request = Postini::API::AutomatedBatch::Displaydomain.new( Postini.auth, domain )
|
18
18
|
response = remote.displaydomain( request )
|
19
19
|
domain_record = response.domainRecord
|
@@ -31,6 +31,12 @@ module Postini
|
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
|
+
# Return a remote port with debug enabled if required
|
35
|
+
def automated_batch_port #:nodoc:
|
36
|
+
remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri )
|
37
|
+
remote.wiredump_dev = Postini.soap4r_wiredump_dev if Postini.soap4r_wiredump?
|
38
|
+
remote
|
39
|
+
end
|
34
40
|
end
|
35
41
|
|
36
42
|
# Setup a new instance with the combination of attributes set
|
@@ -50,9 +56,10 @@ module Postini
|
|
50
56
|
def create
|
51
57
|
return false unless new?
|
52
58
|
|
53
|
-
# TODO: Add
|
59
|
+
# TODO: Add improved validations here
|
60
|
+
return false if @name.nil? || @org.nil?
|
54
61
|
|
55
|
-
remote =
|
62
|
+
remote = automated_batch_port
|
56
63
|
args = Postini::API::AutomatedBatch::Adddomainargs.new( @name )
|
57
64
|
request = Postini::API::AutomatedBatch::Adddomain.new(
|
58
65
|
Postini.auth, @org, args
|
data/lib/postini/user.rb
CHANGED
@@ -20,7 +20,7 @@ module Postini
|
|
20
20
|
# Return a new instance of the user
|
21
21
|
# TODO: Make this take various options just like ActiveRecord
|
22
22
|
def find( user )
|
23
|
-
remote =
|
23
|
+
remote = automated_batch_port( user )
|
24
24
|
request = Postini::API::AutomatedBatch::Displayuser.new( Postini.auth, user )
|
25
25
|
response = remote.displayuser( request )
|
26
26
|
user_record = response.userRecord
|
@@ -38,11 +38,18 @@ module Postini
|
|
38
38
|
|
39
39
|
# Permanently remove the user from Postini
|
40
40
|
def destroy( address )
|
41
|
-
remote =
|
41
|
+
remote = automated_batch_port( address )
|
42
42
|
request = Postini::API::AutomatedBatch::Deleteuser.new( Postini.auth, address )
|
43
43
|
remote.deleteuser( request )
|
44
44
|
end
|
45
45
|
|
46
|
+
# Return a remote port for the address, with debug enabled if required
|
47
|
+
def automated_batch_port( address = nil ) #:nodoc:
|
48
|
+
remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri( address ) )
|
49
|
+
remote.wiredump_dev = Postini.soap4r_wiredump_dev if Postini.soap4r_wiredump?
|
50
|
+
remote
|
51
|
+
end
|
52
|
+
|
46
53
|
end
|
47
54
|
|
48
55
|
# Setup a new instance with the combination of attributes set
|
@@ -64,7 +71,7 @@ module Postini
|
|
64
71
|
# TODO: Add missing validations here
|
65
72
|
return false if @address.nil? || @org.nil?
|
66
73
|
|
67
|
-
remote =
|
74
|
+
remote = automated_batch_port
|
68
75
|
args = Postini::API::AutomatedBatch::Adduserargs.new( @org, welcome )
|
69
76
|
request = Postini::API::AutomatedBatch::Adduser.new( Postini.auth, @address, args )
|
70
77
|
remote.adduser( request )
|
@@ -80,7 +87,7 @@ module Postini
|
|
80
87
|
# Return the list of aliases for the mailbox
|
81
88
|
def aliases
|
82
89
|
if @aliases.nil?
|
83
|
-
remote =
|
90
|
+
remote = self.class.automated_batch_port( @address )
|
84
91
|
query = Postini::API::AutomatedBatch::ListusersqueryParams.new
|
85
92
|
query.aliases = 1
|
86
93
|
query.childorgs = 1
|
@@ -104,7 +111,7 @@ module Postini
|
|
104
111
|
# Add an alias to this user
|
105
112
|
def add_alias( address )
|
106
113
|
@aliases = nil # clear our cache
|
107
|
-
remote =
|
114
|
+
remote = self.class.automated_batch_port( @address )
|
108
115
|
request = Postini::API::AutomatedBatch::Addalias.new( Postini.auth, @address, address )
|
109
116
|
remote.addalias( request )
|
110
117
|
end
|
@@ -112,7 +119,7 @@ module Postini
|
|
112
119
|
# Removes the specified alias
|
113
120
|
def remove_alias( address )
|
114
121
|
@aliases = nil # clear our cache
|
115
|
-
remote =
|
122
|
+
remote = self.class.automated_batch_port( @address )
|
116
123
|
request = Postini::API::AutomatedBatch::Deletealias.new( Postini.auth, address )
|
117
124
|
remote.deletealias( request )
|
118
125
|
end
|
data/lib/postini/version.rb
CHANGED
data/lib/postini.rb
CHANGED
@@ -8,7 +8,9 @@ require 'postini/domain'
|
|
8
8
|
|
9
9
|
require 'postini/api/endpointresolver/EndpointResolverDriver'
|
10
10
|
|
11
|
-
#
|
11
|
+
# = Configuration
|
12
|
+
#
|
13
|
+
# This module just provides access to configuration details used by the rest of
|
12
14
|
# the gem.
|
13
15
|
#
|
14
16
|
# Current configuration values are:
|
@@ -44,10 +46,27 @@ require 'postini/api/endpointresolver/EndpointResolverDriver'
|
|
44
46
|
# Postini.password = 'secret'
|
45
47
|
# Postini.xauth = 'format_unknown_to_author'
|
46
48
|
#
|
49
|
+
# = Debugging
|
50
|
+
#
|
51
|
+
# Lots to debug when an API is classified as "Early access", here are different
|
52
|
+
# controls for setting the debugging verbosity
|
53
|
+
#
|
54
|
+
# * logger = Ruby-logger compatibe logger
|
55
|
+
# * debug = true/false - Enable more verbose logging
|
56
|
+
# * soap4r_wiredump = true/false - Enable soap4r wiredumps
|
57
|
+
# * soap4r_wiredump_dev = DEV - Alternative logfile or device for SOAP4R wiredumps
|
58
|
+
#
|
59
|
+
# Specify a 'Logger' compatible logging facility in order to use the debug
|
60
|
+
# features of the gem. All the other settings increase the verbosity to varying
|
61
|
+
# degrees, and allow you to access some soap4r internals as well.
|
62
|
+
#
|
47
63
|
module Postini
|
48
64
|
|
49
65
|
# On the fly class variable, getter and setter generation...
|
50
|
-
%w{
|
66
|
+
%w{
|
67
|
+
api_key system_number username password xauth
|
68
|
+
logger debug soap4r_debug soap4r_debug_dev soap4r_wiredump soap4r_wiredump_dev
|
69
|
+
}.each do |config|
|
51
70
|
class_eval <<-EOF
|
52
71
|
@@#{config} = nil
|
53
72
|
def self.#{config}=( val )
|
@@ -59,42 +78,65 @@ module Postini
|
|
59
78
|
EOF
|
60
79
|
end
|
61
80
|
|
62
|
-
|
63
|
-
# provided, the endpoint is determined using the Endpoint Resolver Service,
|
64
|
-
# otherwise it is contructed from the +system_number+ configuration value.
|
65
|
-
def self.endpoint_uri( user = nil, service = :automated_batch )
|
66
|
-
raise "System Number not known" if user.nil? && system_number.nil?
|
81
|
+
class << self
|
67
82
|
|
68
|
-
#
|
69
|
-
|
70
|
-
|
71
|
-
|
83
|
+
# Return the appropriate endpoint URI for the service calls. If +user+ is
|
84
|
+
# provided, the endpoint is determined using the Endpoint Resolver Service,
|
85
|
+
# otherwise it is contructed from the +system_number+ configuration value.
|
86
|
+
def endpoint_uri( user = nil, service = :automated_batch )
|
87
|
+
raise "System Number not known" if user.nil? && system_number.nil?
|
88
|
+
|
89
|
+
# Translate the service
|
90
|
+
service = case service
|
91
|
+
when :automated_batch
|
92
|
+
[ Postini::API::EndpointResolver::Service::V2AutomatedBatch, "automatedbatch" ]
|
93
|
+
end
|
94
|
+
|
95
|
+
if user.nil?
|
96
|
+
"https://api-s#{system_number}.postini.com/api2/#{service[1]}"
|
97
|
+
else
|
98
|
+
remote = Postini::API::EndpointResolver::EndpointResolverPort.new
|
99
|
+
remote.wiredump_dev = soap4r_wiredump_dev if soap4r_wiredump?
|
100
|
+
|
101
|
+
request = Postini::API::EndpointResolver::GetServiceEndpoint.new(
|
102
|
+
api_key, user, service[0]
|
103
|
+
)
|
104
|
+
response = remote.getServiceEndpoint( request )
|
105
|
+
response.endpointURI
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def auth( service = :automated_batch, username = nil, password = nil, xauth = nil )
|
110
|
+
username ||= self.username
|
111
|
+
password ||= self.password
|
112
|
+
if password.nil?
|
113
|
+
xauth ||= self.xauth
|
114
|
+
end
|
115
|
+
|
116
|
+
case service
|
117
|
+
when :automated_batch
|
118
|
+
API::AutomatedBatch::AuthElem.new(
|
119
|
+
api_key, username, password, xauth
|
120
|
+
)
|
121
|
+
end
|
72
122
|
end
|
73
123
|
|
74
|
-
|
75
|
-
|
76
|
-
else
|
77
|
-
remote = Postini::API::EndpointResolver::EndpointResolverPort.new
|
78
|
-
request = Postini::API::EndpointResolver::GetServiceEndpoint.new(
|
79
|
-
Postini.api_key, user, service[0]
|
80
|
-
)
|
81
|
-
response = remote.getServiceEndpoint( request )
|
82
|
-
response.endpointURI
|
124
|
+
def debug?
|
125
|
+
@@debug ||= false
|
83
126
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
127
|
+
|
128
|
+
def soap4r_wiredump?
|
129
|
+
@@soap4r_wiredump ||= false
|
130
|
+
end
|
131
|
+
|
132
|
+
def logger
|
133
|
+
@@logger ||= Logger.new('/dev/null')
|
91
134
|
end
|
92
135
|
|
93
|
-
|
94
|
-
|
95
|
-
API::AutomatedBatch::AuthElem.new(
|
96
|
-
api_key, username, password, xauth
|
97
|
-
)
|
136
|
+
def soap4r_wiredump_dev
|
137
|
+
@@soap4r_wiredump_dev ||= soap4r_debug_dev
|
98
138
|
end
|
139
|
+
|
99
140
|
end
|
141
|
+
|
100
142
|
end
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>postini Gem</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/postini4r"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/postini4r" class="numbers">0.0.
|
36
|
+
<a href="http://rubyforge.org/projects/postini4r" class="numbers">0.0.3</a>
|
37
37
|
</div>
|
38
38
|
<h2>Part of the postini4r project</h2>
|
39
39
|
<p>The postini4r project is a collection of sub-projects that aim to implement a broad range of Postini-related tools.</p>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postini
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenneth Kalmer
|
@@ -9,9 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-21 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: soap4r
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.5.8
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: hoe
|
17
27
|
type: :development
|
@@ -83,11 +93,12 @@ has_rdoc: true
|
|
83
93
|
homepage: http://postini4r.rubyforge.org
|
84
94
|
post_install_message: |+
|
85
95
|
|
86
|
-
For more information on postini4r, see
|
87
|
-
|
88
|
-
NOTE: Change this information in PostInstall.txt
|
89
|
-
You can also delete it if you don't want it.
|
96
|
+
For more information on postini4r's postini gem, see
|
97
|
+
http://postini4r.rubyforge.org/postini
|
90
98
|
|
99
|
+
Remember to contact your Postini provider, or Postini directly, to gain access
|
100
|
+
to the Postini Early Access Program. You'll need a unique API key to make use
|
101
|
+
of this gem.
|
91
102
|
|
92
103
|
rdoc_options:
|
93
104
|
- --main
|