DistelliServiceInterface 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/distelli/serviceinterface.rb +92 -0
- metadata +45 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
module Distelli
|
4
|
+
class BaseException < StandardError
|
5
|
+
attr_accessor :err_msg, :err_code, :http_code
|
6
|
+
def initialize(msg=nil, err_code=nil, err_msg=nil, http_code=nil)
|
7
|
+
super(msg)
|
8
|
+
@err_code = err_code
|
9
|
+
if err_msg == nil
|
10
|
+
@err_msg = msg
|
11
|
+
else
|
12
|
+
@err_msg = err_msg
|
13
|
+
end
|
14
|
+
if http_code != nil
|
15
|
+
@http_code = http_code
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class ClientError < BaseException
|
21
|
+
def initialize(msg=nil, err_code=nil, err_msg=nil, http_code=nil)
|
22
|
+
super(msg, err_code, err_msg, http_code)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class ServerError < BaseException
|
27
|
+
def initialize(msg=nil)
|
28
|
+
super(msg, "InternalServerError", "Internal server error", 500)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class InvalidContentType < ClientError
|
33
|
+
def initialize(msg=nil)
|
34
|
+
super(msg, "InvalidContentType", nil, 400)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class InvalidOperationException < ClientError
|
39
|
+
def initialize(msg=nil)
|
40
|
+
super(msg, "InvalidOperation", nil, 400)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class InvalidResponseType < ClientError
|
45
|
+
def initialize(msg=nil)
|
46
|
+
super(msg, "InvalidResponseType", nil, 400)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class MalformedRequest < ClientError
|
51
|
+
def initialize(msg=nil)
|
52
|
+
super(msg, "MalformedRequest", nil, 400)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class OperationNotSupported < ClientError
|
57
|
+
def initialize(msg=nil)
|
58
|
+
super(msg, "OperationNotSupported", nil, 400)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class ServiceConstants
|
63
|
+
CONTENT_TYPE_JSON = "application/json"
|
64
|
+
CONTENT_TYPE_XML = "text/xml"
|
65
|
+
CONTENT_TYPE_OCTET_STREAM = "application/octet-stream"
|
66
|
+
HTTP_METHOD_GET = "GET"
|
67
|
+
HTTP_METHOD_PUT = "PUT"
|
68
|
+
HTTP_METHOD_POST = "POST"
|
69
|
+
HTTP_METHOD_DELETE = "DELETE"
|
70
|
+
RESPONSE_TYPE_XML = "xml"
|
71
|
+
RESPONSE_TYPE_JSON = "json"
|
72
|
+
#Headers
|
73
|
+
AUTHORIZATION_HEADER = "Authorization"
|
74
|
+
CONTENT_MD5_HEADER = "Content-MD5"
|
75
|
+
DATE_HEADER = "Date"
|
76
|
+
DISTELLI_DATE_HEADER = "x-dstli-date"
|
77
|
+
OPERATION_HEADER = "x-dstli-op"
|
78
|
+
RESPONSE_TYPE_HEADER = "x-dstli-rtype"
|
79
|
+
CONTENT_TYPE_HEADER = "Content-Type"
|
80
|
+
REQUEST_ID_HEADER = "x-dstli-rid"
|
81
|
+
SERVER_HEADER = "Server"
|
82
|
+
#Query Params
|
83
|
+
OPERATION_PARAM = "_op"
|
84
|
+
RESPONSE_TYPE_PARAM = "_rtype"
|
85
|
+
REQUEST_ID_PARAM = "_rid"
|
86
|
+
#Keys
|
87
|
+
ERROR_KEY = "Error"
|
88
|
+
ERR_CODE_KEY = "code"
|
89
|
+
ERR_MSG_KEY = "message"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: DistelliServiceInterface
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rahul Singh
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-04 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Distelli Service Interface for Ruby Servers and Clients
|
15
|
+
email: rsingh@distelli.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/distelli/serviceinterface.rb
|
21
|
+
homepage: http://www.distelli.com/
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.23
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Distelli Service Interface classes
|
45
|
+
test_files: []
|