microsoft_graph 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +11 -11
- data/.rspec +2 -2
- data/.travis.yml +4 -4
- data/Gemfile +4 -4
- data/LICENSE +10 -10
- data/README.md +99 -98
- data/Rakefile +7 -7
- data/data/metadata_v1.0.xml +1686 -1686
- data/integration_spec/integration_spec_helper.rb +18 -18
- data/integration_spec/live_spec.rb +180 -180
- data/lib/microsoft_graph.rb +35 -35
- data/lib/microsoft_graph/base.rb +110 -110
- data/lib/microsoft_graph/base_entity.rb +152 -152
- data/lib/microsoft_graph/cached_metadata_directory.rb +3 -3
- data/lib/microsoft_graph/class_builder.rb +217 -217
- data/lib/microsoft_graph/collection.rb +95 -95
- data/lib/microsoft_graph/collection_association.rb +232 -232
- data/lib/microsoft_graph/errors.rb +6 -6
- data/lib/microsoft_graph/version.rb +3 -3
- data/lib/odata.rb +49 -49
- data/lib/odata/entity_set.rb +20 -20
- data/lib/odata/errors.rb +18 -18
- data/lib/odata/navigation_property.rb +30 -30
- data/lib/odata/operation.rb +17 -17
- data/lib/odata/property.rb +38 -38
- data/lib/odata/request.rb +49 -49
- data/lib/odata/service.rb +279 -279
- data/lib/odata/singleton.rb +20 -20
- data/lib/odata/type.rb +25 -25
- data/lib/odata/types/collection_type.rb +30 -30
- data/lib/odata/types/complex_type.rb +19 -19
- data/lib/odata/types/entity_type.rb +33 -33
- data/lib/odata/types/enum_type.rb +37 -37
- data/lib/odata/types/primitive_type.rb +12 -12
- data/lib/odata/types/primitive_types/binary_type.rb +15 -15
- data/lib/odata/types/primitive_types/boolean_type.rb +15 -15
- data/lib/odata/types/primitive_types/date_time_offset_type.rb +15 -15
- data/lib/odata/types/primitive_types/date_type.rb +23 -23
- data/lib/odata/types/primitive_types/double_type.rb +16 -16
- data/lib/odata/types/primitive_types/guid_type.rb +24 -24
- data/lib/odata/types/primitive_types/int_16_type.rb +19 -19
- data/lib/odata/types/primitive_types/int_32_type.rb +15 -15
- data/lib/odata/types/primitive_types/int_64_type.rb +15 -15
- data/lib/odata/types/primitive_types/stream_type.rb +15 -15
- data/lib/odata/types/primitive_types/string_type.rb +15 -15
- data/microsoft_graph-0.1.2.gem +0 -0
- data/microsoft_graph.gemspec +31 -31
- data/tasks/update_metadata.rb +17 -17
- metadata +6 -6
- data/microsoft_graph-0.1.0.gem +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
class MicrosoftGraph
|
2
|
-
class TypeError < ::TypeError; end
|
3
|
-
class NonNullableError < TypeError; end
|
4
|
-
class NoGraphError < ::RuntimeError; end
|
5
|
-
class NoAssociationError < ::RuntimeError; end
|
6
|
-
end
|
1
|
+
class MicrosoftGraph
|
2
|
+
class TypeError < ::TypeError; end
|
3
|
+
class NonNullableError < TypeError; end
|
4
|
+
class NoGraphError < ::RuntimeError; end
|
5
|
+
class NoAssociationError < ::RuntimeError; end
|
6
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class MicrosoftGraph
|
2
|
-
VERSION = "0.1.
|
3
|
-
end
|
1
|
+
class MicrosoftGraph
|
2
|
+
VERSION = "0.1.3"
|
3
|
+
end
|
data/lib/odata.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
Dir[
|
4
|
-
File.join(
|
5
|
-
File.dirname(__FILE__),
|
6
|
-
'odata',
|
7
|
-
'*.rb'
|
8
|
-
)
|
9
|
-
].sort.each { |f| require f }
|
10
|
-
|
11
|
-
module OData
|
12
|
-
|
13
|
-
def self.convert_to_snake_case(str)
|
14
|
-
first_letter, rest = str.to_s.split("", 2)
|
15
|
-
"#{first_letter}#{rest.to_s.gsub(/([A-Z])/, '_\1')}".downcase
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.convert_to_camel_case(str)
|
19
|
-
first_letter, rest = str.to_s.split("", 2)
|
20
|
-
cameled_rest = rest.gsub(/_(.)/) { |l| l[1].upcase }
|
21
|
-
first_letter.downcase.concat(cameled_rest)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.convert_keys_to_snake_case(properties)
|
25
|
-
if properties.respond_to? :keys
|
26
|
-
results = {}
|
27
|
-
properties.each do |key, value|
|
28
|
-
results[convert_to_snake_case(key)] = convert_keys_to_snake_case(value)
|
29
|
-
end
|
30
|
-
results
|
31
|
-
else
|
32
|
-
properties
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.convert_keys_to_camel_case(properties)
|
37
|
-
if properties.respond_to? :keys
|
38
|
-
results = {}
|
39
|
-
properties.each do |key, value|
|
40
|
-
results[convert_to_camel_case(key)] = convert_keys_to_camel_case(value)
|
41
|
-
end
|
42
|
-
results
|
43
|
-
elsif properties.is_a? Array
|
44
|
-
properties.map { |m| convert_keys_to_camel_case(m) }
|
45
|
-
else
|
46
|
-
properties
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
Dir[
|
4
|
+
File.join(
|
5
|
+
File.dirname(__FILE__),
|
6
|
+
'odata',
|
7
|
+
'*.rb'
|
8
|
+
)
|
9
|
+
].sort.each { |f| require f }
|
10
|
+
|
11
|
+
module OData
|
12
|
+
|
13
|
+
def self.convert_to_snake_case(str)
|
14
|
+
first_letter, rest = str.to_s.split("", 2)
|
15
|
+
"#{first_letter}#{rest.to_s.gsub(/([A-Z])/, '_\1')}".downcase
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.convert_to_camel_case(str)
|
19
|
+
first_letter, rest = str.to_s.split("", 2)
|
20
|
+
cameled_rest = rest.gsub(/_(.)/) { |l| l[1].upcase }
|
21
|
+
first_letter.downcase.concat(cameled_rest)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.convert_keys_to_snake_case(properties)
|
25
|
+
if properties.respond_to? :keys
|
26
|
+
results = {}
|
27
|
+
properties.each do |key, value|
|
28
|
+
results[convert_to_snake_case(key)] = convert_keys_to_snake_case(value)
|
29
|
+
end
|
30
|
+
results
|
31
|
+
else
|
32
|
+
properties
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.convert_keys_to_camel_case(properties)
|
37
|
+
if properties.respond_to? :keys
|
38
|
+
results = {}
|
39
|
+
properties.each do |key, value|
|
40
|
+
results[convert_to_camel_case(key)] = convert_keys_to_camel_case(value)
|
41
|
+
end
|
42
|
+
results
|
43
|
+
elsif properties.is_a? Array
|
44
|
+
properties.map { |m| convert_keys_to_camel_case(m) }
|
45
|
+
else
|
46
|
+
properties
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/odata/entity_set.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
module OData
|
2
|
-
class EntitySet
|
3
|
-
attr_reader :name
|
4
|
-
attr_reader :member_type
|
5
|
-
|
6
|
-
def initialize(options = {})
|
7
|
-
@name = options[:name]
|
8
|
-
@member_type = options[:member_type]
|
9
|
-
@service = options[:service]
|
10
|
-
end
|
11
|
-
|
12
|
-
def collection?
|
13
|
-
true
|
14
|
-
end
|
15
|
-
|
16
|
-
def type
|
17
|
-
@service.get_type_by_name("Collection(#{member_type})")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
1
|
+
module OData
|
2
|
+
class EntitySet
|
3
|
+
attr_reader :name
|
4
|
+
attr_reader :member_type
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
@name = options[:name]
|
8
|
+
@member_type = options[:member_type]
|
9
|
+
@service = options[:service]
|
10
|
+
end
|
11
|
+
|
12
|
+
def collection?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def type
|
17
|
+
@service.get_type_by_name("Collection(#{member_type})")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/odata/errors.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
module OData
|
2
|
-
class Error < RuntimeError; end
|
3
|
-
|
4
|
-
class HTTPError < Error
|
5
|
-
def initialize(response)
|
6
|
-
body = JSON.parse(response.body)
|
7
|
-
super "#{response.code} #{body['error']['code']}: \"#{body['error']['message']}\" from \"#{response.uri}\""
|
8
|
-
rescue
|
9
|
-
super
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class ClientError < HTTPError; end
|
14
|
-
class ServerError < HTTPError; end
|
15
|
-
|
16
|
-
class AuthenticationError < ClientError; end
|
17
|
-
class AuthorizationError < ClientError; end
|
18
|
-
end
|
1
|
+
module OData
|
2
|
+
class Error < RuntimeError; end
|
3
|
+
|
4
|
+
class HTTPError < Error
|
5
|
+
def initialize(response)
|
6
|
+
body = JSON.parse(response.body)
|
7
|
+
super "#{response.code} #{body['error']['code']}: \"#{body['error']['message']}\" from \"#{response.uri}\""
|
8
|
+
rescue
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ClientError < HTTPError; end
|
14
|
+
class ServerError < HTTPError; end
|
15
|
+
|
16
|
+
class AuthenticationError < ClientError; end
|
17
|
+
class AuthorizationError < ClientError; end
|
18
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
module OData
|
2
|
-
class NavigationProperty
|
3
|
-
attr_reader :name
|
4
|
-
attr_reader :type
|
5
|
-
attr_reader :nullable
|
6
|
-
attr_reader :contain_target
|
7
|
-
attr_reader :partner
|
8
|
-
|
9
|
-
def initialize(options = {})
|
10
|
-
@name = options[:name]
|
11
|
-
@type = options[:type]
|
12
|
-
@nullable = options[:nullable].nil? ? true : false
|
13
|
-
@contain_target = options[:contain_target] || false
|
14
|
-
@partner = options[:partner]
|
15
|
-
end
|
16
|
-
|
17
|
-
def collection?
|
18
|
-
OData::CollectionType === type
|
19
|
-
end
|
20
|
-
|
21
|
-
def type_match?(value)
|
22
|
-
type.valid_value?(value)
|
23
|
-
end
|
24
|
-
|
25
|
-
def collection_type_match?(value)
|
26
|
-
collection = type
|
27
|
-
collection.valid_value?(value)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
module OData
|
2
|
+
class NavigationProperty
|
3
|
+
attr_reader :name
|
4
|
+
attr_reader :type
|
5
|
+
attr_reader :nullable
|
6
|
+
attr_reader :contain_target
|
7
|
+
attr_reader :partner
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@name = options[:name]
|
11
|
+
@type = options[:type]
|
12
|
+
@nullable = options[:nullable].nil? ? true : false
|
13
|
+
@contain_target = options[:contain_target] || false
|
14
|
+
@partner = options[:partner]
|
15
|
+
end
|
16
|
+
|
17
|
+
def collection?
|
18
|
+
OData::CollectionType === type
|
19
|
+
end
|
20
|
+
|
21
|
+
def type_match?(value)
|
22
|
+
type.valid_value?(value)
|
23
|
+
end
|
24
|
+
|
25
|
+
def collection_type_match?(value)
|
26
|
+
collection = type
|
27
|
+
collection.valid_value?(value)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/odata/operation.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
module OData
|
2
|
-
class Operation
|
3
|
-
attr_reader :name
|
4
|
-
attr_reader :binding_type
|
5
|
-
attr_reader :entity_set_type
|
6
|
-
attr_reader :parameters
|
7
|
-
attr_reader :return_type
|
8
|
-
|
9
|
-
def initialize(options = {})
|
10
|
-
@name = options[:name]
|
11
|
-
@entity_set_type = options[:entity_set_type]
|
12
|
-
@binding_type = options[:binding_type]
|
13
|
-
@parameters = options[:parameters]
|
14
|
-
@return_type = options[:return_type]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
module OData
|
2
|
+
class Operation
|
3
|
+
attr_reader :name
|
4
|
+
attr_reader :binding_type
|
5
|
+
attr_reader :entity_set_type
|
6
|
+
attr_reader :parameters
|
7
|
+
attr_reader :return_type
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@name = options[:name]
|
11
|
+
@entity_set_type = options[:entity_set_type]
|
12
|
+
@binding_type = options[:binding_type]
|
13
|
+
@parameters = options[:parameters]
|
14
|
+
@return_type = options[:return_type]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/odata/property.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
module OData
|
4
|
-
class Property
|
5
|
-
attr_reader :name
|
6
|
-
attr_reader :nullable
|
7
|
-
attr_reader :type
|
8
|
-
|
9
|
-
def initialize(options = {})
|
10
|
-
@name = options[:name]
|
11
|
-
@nullable = options[:nullable]
|
12
|
-
@type = options[:type]
|
13
|
-
end
|
14
|
-
|
15
|
-
def collection?
|
16
|
-
OData::CollectionType === type
|
17
|
-
end
|
18
|
-
|
19
|
-
def coerce_to_type(value)
|
20
|
-
return nil if value.nil?
|
21
|
-
type.coerce(value)
|
22
|
-
end
|
23
|
-
|
24
|
-
def collection_type_match?(value)
|
25
|
-
collection = type
|
26
|
-
collection.valid_value?(value)
|
27
|
-
end
|
28
|
-
|
29
|
-
def type_match?(value)
|
30
|
-
type.valid_value?(value) || (value.nil? && nullable)
|
31
|
-
end
|
32
|
-
|
33
|
-
def nullable_match?(value)
|
34
|
-
nullable || !value.nil?
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module OData
|
4
|
+
class Property
|
5
|
+
attr_reader :name
|
6
|
+
attr_reader :nullable
|
7
|
+
attr_reader :type
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@name = options[:name]
|
11
|
+
@nullable = options[:nullable]
|
12
|
+
@type = options[:type]
|
13
|
+
end
|
14
|
+
|
15
|
+
def collection?
|
16
|
+
OData::CollectionType === type
|
17
|
+
end
|
18
|
+
|
19
|
+
def coerce_to_type(value)
|
20
|
+
return nil if value.nil?
|
21
|
+
type.coerce(value)
|
22
|
+
end
|
23
|
+
|
24
|
+
def collection_type_match?(value)
|
25
|
+
collection = type
|
26
|
+
collection.valid_value?(value)
|
27
|
+
end
|
28
|
+
|
29
|
+
def type_match?(value)
|
30
|
+
type.valid_value?(value) || (value.nil? && nullable)
|
31
|
+
end
|
32
|
+
|
33
|
+
def nullable_match?(value)
|
34
|
+
nullable || !value.nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/lib/odata/request.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
module OData
|
2
|
-
class Request
|
3
|
-
attr_accessor :headers
|
4
|
-
attr_accessor :uri
|
5
|
-
attr_accessor :method
|
6
|
-
attr_accessor :data
|
7
|
-
|
8
|
-
def initialize(method = :get, uri = '', data = nil)
|
9
|
-
@method = method.to_s.downcase.to_sym
|
10
|
-
@uri = URI(uri)
|
11
|
-
@data = data
|
12
|
-
@headers = {
|
13
|
-
'Content-Type' => 'application/json',
|
14
|
-
'SdkVersion' => 'Graph-ruby-0.1.0'
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def perform
|
19
|
-
response = Net::HTTP
|
20
|
-
.new(uri.hostname, uri.port)
|
21
|
-
.tap { |h| h.use_ssl = true }
|
22
|
-
.send(*send_params)
|
23
|
-
raise ServerError.new(response) unless response.code.to_i < 500
|
24
|
-
raise AuthenticationError.new(response) if response.code.to_i == 401
|
25
|
-
raise AuthorizationError.new(response) if response.code.to_i == 403
|
26
|
-
raise ClientError.new(response) unless response.code.to_i < 400
|
27
|
-
if response.body
|
28
|
-
begin
|
29
|
-
OData.convert_keys_to_snake_case(JSON.parse(response.body))
|
30
|
-
rescue JSON::ParserError => e
|
31
|
-
{}
|
32
|
-
end
|
33
|
-
else
|
34
|
-
{}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def send_params
|
41
|
-
base_params = [
|
42
|
-
method,
|
43
|
-
uri
|
44
|
-
]
|
45
|
-
base_params << data if data
|
46
|
-
base_params << headers
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
module OData
|
2
|
+
class Request
|
3
|
+
attr_accessor :headers
|
4
|
+
attr_accessor :uri
|
5
|
+
attr_accessor :method
|
6
|
+
attr_accessor :data
|
7
|
+
|
8
|
+
def initialize(method = :get, uri = '', data = nil)
|
9
|
+
@method = method.to_s.downcase.to_sym
|
10
|
+
@uri = URI(uri)
|
11
|
+
@data = data
|
12
|
+
@headers = {
|
13
|
+
'Content-Type' => 'application/json',
|
14
|
+
'SdkVersion' => 'Graph-ruby-0.1.0'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def perform
|
19
|
+
response = Net::HTTP
|
20
|
+
.new(uri.hostname, uri.port)
|
21
|
+
.tap { |h| h.use_ssl = true }
|
22
|
+
.send(*send_params)
|
23
|
+
raise ServerError.new(response) unless response.code.to_i < 500
|
24
|
+
raise AuthenticationError.new(response) if response.code.to_i == 401
|
25
|
+
raise AuthorizationError.new(response) if response.code.to_i == 403
|
26
|
+
raise ClientError.new(response) unless response.code.to_i < 400
|
27
|
+
if response.body
|
28
|
+
begin
|
29
|
+
OData.convert_keys_to_snake_case(JSON.parse(response.body))
|
30
|
+
rescue JSON::ParserError => e
|
31
|
+
{}
|
32
|
+
end
|
33
|
+
else
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def send_params
|
41
|
+
base_params = [
|
42
|
+
method,
|
43
|
+
uri
|
44
|
+
]
|
45
|
+
base_params << data if data
|
46
|
+
base_params << headers
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|