occi-api 4.0.0.beta.1 → 4.0.0.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/occi/api/client/client_base.rb +28 -40
- data/lib/occi/api/client/client_http.rb +8 -7
- data/lib/occi/api/version.rb +1 -1
- metadata +2 -2
@@ -346,17 +346,23 @@ module Occi
|
|
346
346
|
found_ary.any? ? found_ary.first : nil
|
347
347
|
end
|
348
348
|
|
349
|
+
# Looks up a mixin with a specific type, will return
|
350
|
+
# mixin's full description.
|
349
351
|
#
|
350
|
-
#
|
351
|
-
#
|
352
|
+
# @param [String] name of the mixin
|
353
|
+
# @param [String] type of the mixin
|
354
|
+
# @return [Occi::Collection] mixin description
|
352
355
|
def describe_mixin_w_type(name, type)
|
353
356
|
return unless %w( os_tpl resource_tpl ).include? type.to_s
|
354
357
|
send("get_#{type.to_s}s".to_sym).select { |mixin| mixin.term == name }
|
355
358
|
end
|
356
359
|
|
360
|
+
# Looks up a mixin in all available mixin types, will
|
361
|
+
# return mixin's full description. Returns always the
|
362
|
+
# first match found, search will start in os_tpl.
|
357
363
|
#
|
358
|
-
#
|
359
|
-
#
|
364
|
+
# @param [String] name of the mixin
|
365
|
+
# @return [Occi::Collection] mixin description
|
360
366
|
def describe_mixin_wo_type(name)
|
361
367
|
%w( os_tpl resource_tpl ).each do |type|
|
362
368
|
found = send("get_#{type}s".to_sym).select { |mixin| mixin.term == name }
|
@@ -466,36 +472,6 @@ module Occi
|
|
466
472
|
end
|
467
473
|
alias_method :get_resource_tpls, :get_resource_templates
|
468
474
|
|
469
|
-
# Creates a link of a specified kind and binds it to the given resource.
|
470
|
-
#
|
471
|
-
# @example
|
472
|
-
# link_kind = 'http://schemas.ogf.org/occi/infrastructure#storagelink'
|
473
|
-
# compute = client.get_resource "compute"
|
474
|
-
# storage_location = "http://localhost:3300/storage/321df21adfad-f3adfa5f4adf-a3d54ffadffe"
|
475
|
-
# linked_resource_kind = 'http://schemas.ogf.org/occi/infrastructure#storage'
|
476
|
-
#
|
477
|
-
# link link_kind, compute, storage_location, linked_resource_kind
|
478
|
-
#
|
479
|
-
# @param [String] link type identifier (link kind)
|
480
|
-
# @param [Occi::Core::Resource] resource to link to
|
481
|
-
# @param [URI, String] resource to be linked
|
482
|
-
# @param [String] type identifier of the linked resource
|
483
|
-
# @param [Occi::Core::Attributes] link attributes
|
484
|
-
# @param [Array<String>] link mixins
|
485
|
-
# @return [Occi::Core::Link] link instance
|
486
|
-
def link(kind, source, target_location, target_kind, attributes=Occi::Core::Attributes.new, mixins=[])
|
487
|
-
link = Occi::Core::Link.new(kind)
|
488
|
-
link.mixins = mixins
|
489
|
-
link.attributes = attributes
|
490
|
-
link.target = (target_location.kind_of? URI::Generic) ? target_location.path : target_location.to_s
|
491
|
-
link.rel = target_kind
|
492
|
-
|
493
|
-
link.check @model
|
494
|
-
source.links << link
|
495
|
-
|
496
|
-
link
|
497
|
-
end
|
498
|
-
|
499
475
|
# Returns the path for a given resource type identifier
|
500
476
|
#
|
501
477
|
# @example
|
@@ -543,6 +519,10 @@ module Occi
|
|
543
519
|
|
544
520
|
protected
|
545
521
|
|
522
|
+
##############################################################################
|
523
|
+
######## STUBS START
|
524
|
+
##############################################################################
|
525
|
+
|
546
526
|
# Sets auth method and appropriate httparty attributes. Supported auth methods
|
547
527
|
# are: ["basic", "digest", "x509", "none"]
|
548
528
|
#
|
@@ -571,6 +551,10 @@ module Occi
|
|
571
551
|
# @return [String] chosen media type
|
572
552
|
def set_media_type(force_type = nil); end
|
573
553
|
|
554
|
+
##############################################################################
|
555
|
+
######## STUBS END
|
556
|
+
##############################################################################
|
557
|
+
|
574
558
|
# Sets the logger and log levels. This allows users to pass existing logger
|
575
559
|
# instances to the rOCCI client.
|
576
560
|
#
|
@@ -618,23 +602,27 @@ module Occi
|
|
618
602
|
@model
|
619
603
|
end
|
620
604
|
|
605
|
+
# Returns mixin type identifiers for os_tpl mixins
|
606
|
+
# in an array.
|
621
607
|
#
|
622
|
-
#
|
623
|
-
#
|
608
|
+
# @return [Array] array of os_tpl mixin identifiers
|
624
609
|
def get_os_tpl_mixins_ary
|
625
610
|
get_mixins_ary(:os_tpl)
|
626
611
|
end
|
627
612
|
|
613
|
+
# Returns mixin type identifiers for resource_tpl mixins
|
614
|
+
# in an array.
|
628
615
|
#
|
629
|
-
#
|
630
|
-
#
|
616
|
+
# @return [Array] array of resource_tpl mixin identifiers
|
631
617
|
def get_resource_tpl_mixins_ary
|
632
618
|
get_mixins_ary(:resource_tpl)
|
633
619
|
end
|
634
620
|
|
621
|
+
# Returns mixin type identifiers for given mixin type
|
622
|
+
# in an array.
|
635
623
|
#
|
636
|
-
#
|
637
|
-
#
|
624
|
+
# @param [Symbol] mixin type
|
625
|
+
# @return [Array] array of mixin identifiers
|
638
626
|
def get_mixins_ary(mixin_type)
|
639
627
|
mixins = []
|
640
628
|
|
@@ -14,9 +14,14 @@ module Occi
|
|
14
14
|
# HTTParty for raw HTTP requests
|
15
15
|
include HTTParty
|
16
16
|
|
17
|
-
# TODO:
|
18
|
-
#
|
19
|
-
|
17
|
+
# TODO: change default Accept to JSON as soon as it is properly
|
18
|
+
# implemented in OpenStack's OCCI-OS
|
19
|
+
# 'Accept' => 'application/occi+json,text/plain;q=0.8,text/occi;q=0.2'
|
20
|
+
DEFAULT_HEADERS = {
|
21
|
+
'Accept' => 'text/plain,text/occi;q=0.2',
|
22
|
+
'User-Agent' => "rOCCI HTTPClient #{Occi::Api::VERSION}"
|
23
|
+
}
|
24
|
+
headers DEFAULT_HEADERS
|
20
25
|
|
21
26
|
# hash mapping HTTP response codes to human-readable messages
|
22
27
|
HTTP_CODES = {
|
@@ -169,10 +174,6 @@ module Occi
|
|
169
174
|
|
170
175
|
raise "#{entity} not an entity!" unless entity.kind_of? Occi::Core::Entity
|
171
176
|
|
172
|
-
# is this entity valid?
|
173
|
-
entity.model = @model
|
174
|
-
entity.check
|
175
|
-
|
176
177
|
Occi::Log.debug "Entity kind: #{entity.kind}"
|
177
178
|
kind = entity.kind
|
178
179
|
raise "No kind found for #{entity}" unless kind
|
data/lib/occi/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.beta.
|
4
|
+
version: 4.0.0.beta.2
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: occi-core
|