id
int32 0
24.9k
| repo
stringlengths 5
58
| path
stringlengths 9
168
| func_name
stringlengths 9
130
| original_string
stringlengths 66
10.5k
| language
stringclasses 1
value | code
stringlengths 66
10.5k
| code_tokens
list | docstring
stringlengths 8
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 94
266
|
|---|---|---|---|---|---|---|---|---|---|---|---|
20,700
|
raw1z/amistad
|
lib/amistad/active_record_friendship_model.rb
|
Amistad.ActiveRecordFriendshipModel.can_block?
|
def can_block?(friendable)
active? && (approved? || (pending? && self.friend_id == friendable.id && friendable.class.to_s == Amistad.friend_model))
end
|
ruby
|
def can_block?(friendable)
active? && (approved? || (pending? && self.friend_id == friendable.id && friendable.class.to_s == Amistad.friend_model))
end
|
[
"def",
"can_block?",
"(",
"friendable",
")",
"active?",
"&&",
"(",
"approved?",
"||",
"(",
"pending?",
"&&",
"self",
".",
"friend_id",
"==",
"friendable",
".",
"id",
"&&",
"friendable",
".",
"class",
".",
"to_s",
"==",
"Amistad",
".",
"friend_model",
")",
")",
"end"
] |
returns true if a friendship can be blocked by given friendable
|
[
"returns",
"true",
"if",
"a",
"friendship",
"can",
"be",
"blocked",
"by",
"given",
"friendable"
] |
3da822509611450e4777f6571ea0967fd5bf6602
|
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/active_record_friendship_model.rb#L43-L45
|
20,701
|
raw1z/amistad
|
lib/amistad/active_record_friendship_model.rb
|
Amistad.ActiveRecordFriendshipModel.can_unblock?
|
def can_unblock?(friendable)
blocked? && self.blocker_id == friendable.id && friendable.class.to_s == Amistad.friend_model
end
|
ruby
|
def can_unblock?(friendable)
blocked? && self.blocker_id == friendable.id && friendable.class.to_s == Amistad.friend_model
end
|
[
"def",
"can_unblock?",
"(",
"friendable",
")",
"blocked?",
"&&",
"self",
".",
"blocker_id",
"==",
"friendable",
".",
"id",
"&&",
"friendable",
".",
"class",
".",
"to_s",
"==",
"Amistad",
".",
"friend_model",
"end"
] |
returns true if a friendship can be unblocked by given friendable
|
[
"returns",
"true",
"if",
"a",
"friendship",
"can",
"be",
"unblocked",
"by",
"given",
"friendable"
] |
3da822509611450e4777f6571ea0967fd5bf6602
|
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/active_record_friendship_model.rb#L48-L50
|
20,702
|
rktjmp/tileup
|
lib/tileup/logger.rb
|
TileUp.TileUpLogger.add
|
def add(severity, message)
severity = TileUpLogger.sym_to_severity(severity)
logger.add(severity, message)
end
|
ruby
|
def add(severity, message)
severity = TileUpLogger.sym_to_severity(severity)
logger.add(severity, message)
end
|
[
"def",
"add",
"(",
"severity",
",",
"message",
")",
"severity",
"=",
"TileUpLogger",
".",
"sym_to_severity",
"(",
"severity",
")",
"logger",
".",
"add",
"(",
"severity",
",",
"message",
")",
"end"
] |
add message to log
|
[
"add",
"message",
"to",
"log"
] |
5002151f8603ea5d4af76892081af85d9deff9fb
|
https://github.com/rktjmp/tileup/blob/5002151f8603ea5d4af76892081af85d9deff9fb/lib/tileup/logger.rb#L62-L65
|
20,703
|
cloudfoundry-community/bosh-gen
|
lib/bosh/gen/bosh-config.rb
|
Bosh::Cli.Config.deployment
|
def deployment
return nil if target.nil?
if @config_file.has_key?("deployment")
if is_old_deployment_config?
set_deployment(@config_file["deployment"])
save
end
if @config_file["deployment"].is_a?(Hash)
return @config_file["deployment"][target]
end
end
end
|
ruby
|
def deployment
return nil if target.nil?
if @config_file.has_key?("deployment")
if is_old_deployment_config?
set_deployment(@config_file["deployment"])
save
end
if @config_file["deployment"].is_a?(Hash)
return @config_file["deployment"][target]
end
end
end
|
[
"def",
"deployment",
"return",
"nil",
"if",
"target",
".",
"nil?",
"if",
"@config_file",
".",
"has_key?",
"(",
"\"deployment\"",
")",
"if",
"is_old_deployment_config?",
"set_deployment",
"(",
"@config_file",
"[",
"\"deployment\"",
"]",
")",
"save",
"end",
"if",
"@config_file",
"[",
"\"deployment\"",
"]",
".",
"is_a?",
"(",
"Hash",
")",
"return",
"@config_file",
"[",
"\"deployment\"",
"]",
"[",
"target",
"]",
"end",
"end",
"end"
] |
Read the deployment configuration. Return the deployment for the
current target.
@return [String?] The deployment path for the current target.
|
[
"Read",
"the",
"deployment",
"configuration",
".",
"Return",
"the",
"deployment",
"for",
"the",
"current",
"target",
"."
] |
73022585f762fa75f021bfd35b2e3f9096c99c74
|
https://github.com/cloudfoundry-community/bosh-gen/blob/73022585f762fa75f021bfd35b2e3f9096c99c74/lib/bosh/gen/bosh-config.rb#L151-L162
|
20,704
|
hcatlin/make_resourceful
|
lib/resourceful/builder.rb
|
Resourceful.Builder.apply
|
def apply
apply_publish
kontroller = @controller
Resourceful::ACTIONS.each do |action_named|
# See if this is a method listed by #actions
unless @ok_actions.include? action_named
# If its not listed, then remove the method
# No one can hit it... if its DEAD!
@action_module.send :remove_method, action_named
end
end
kontroller.hidden_actions.reject! &@ok_actions.method(:include?)
kontroller.send :include, @action_module
merged_callbacks = kontroller.resourceful_callbacks.merge @callbacks
merged_responses = kontroller.resourceful_responses.merge @responses
kontroller.resourceful_callbacks = merged_callbacks
kontroller.resourceful_responses = merged_responses
kontroller.made_resourceful = true
kontroller.parents = @parents
kontroller.shallow_parent = @shallow_parent
kontroller.model_namespace = @model_namespace
kontroller.before_filter :load_object, :only => (@ok_actions & SINGULAR_PRELOADED_ACTIONS) + @custom_member_actions
kontroller.before_filter :load_objects, :only => (@ok_actions & PLURAL_ACTIONS) + @custom_collection_actions
kontroller.before_filter :load_parent_object, :only => @ok_actions + @custom_member_actions + @custom_collection_actions
end
|
ruby
|
def apply
apply_publish
kontroller = @controller
Resourceful::ACTIONS.each do |action_named|
# See if this is a method listed by #actions
unless @ok_actions.include? action_named
# If its not listed, then remove the method
# No one can hit it... if its DEAD!
@action_module.send :remove_method, action_named
end
end
kontroller.hidden_actions.reject! &@ok_actions.method(:include?)
kontroller.send :include, @action_module
merged_callbacks = kontroller.resourceful_callbacks.merge @callbacks
merged_responses = kontroller.resourceful_responses.merge @responses
kontroller.resourceful_callbacks = merged_callbacks
kontroller.resourceful_responses = merged_responses
kontroller.made_resourceful = true
kontroller.parents = @parents
kontroller.shallow_parent = @shallow_parent
kontroller.model_namespace = @model_namespace
kontroller.before_filter :load_object, :only => (@ok_actions & SINGULAR_PRELOADED_ACTIONS) + @custom_member_actions
kontroller.before_filter :load_objects, :only => (@ok_actions & PLURAL_ACTIONS) + @custom_collection_actions
kontroller.before_filter :load_parent_object, :only => @ok_actions + @custom_member_actions + @custom_collection_actions
end
|
[
"def",
"apply",
"apply_publish",
"kontroller",
"=",
"@controller",
"Resourceful",
"::",
"ACTIONS",
".",
"each",
"do",
"|",
"action_named",
"|",
"# See if this is a method listed by #actions",
"unless",
"@ok_actions",
".",
"include?",
"action_named",
"# If its not listed, then remove the method",
"# No one can hit it... if its DEAD!",
"@action_module",
".",
"send",
":remove_method",
",",
"action_named",
"end",
"end",
"kontroller",
".",
"hidden_actions",
".",
"reject!",
"@ok_actions",
".",
"method",
"(",
":include?",
")",
"kontroller",
".",
"send",
":include",
",",
"@action_module",
"merged_callbacks",
"=",
"kontroller",
".",
"resourceful_callbacks",
".",
"merge",
"@callbacks",
"merged_responses",
"=",
"kontroller",
".",
"resourceful_responses",
".",
"merge",
"@responses",
"kontroller",
".",
"resourceful_callbacks",
"=",
"merged_callbacks",
"kontroller",
".",
"resourceful_responses",
"=",
"merged_responses",
"kontroller",
".",
"made_resourceful",
"=",
"true",
"kontroller",
".",
"parents",
"=",
"@parents",
"kontroller",
".",
"shallow_parent",
"=",
"@shallow_parent",
"kontroller",
".",
"model_namespace",
"=",
"@model_namespace",
"kontroller",
".",
"before_filter",
":load_object",
",",
":only",
"=>",
"(",
"@ok_actions",
"&",
"SINGULAR_PRELOADED_ACTIONS",
")",
"+",
"@custom_member_actions",
"kontroller",
".",
"before_filter",
":load_objects",
",",
":only",
"=>",
"(",
"@ok_actions",
"&",
"PLURAL_ACTIONS",
")",
"+",
"@custom_collection_actions",
"kontroller",
".",
"before_filter",
":load_parent_object",
",",
":only",
"=>",
"@ok_actions",
"+",
"@custom_member_actions",
"+",
"@custom_collection_actions",
"end"
] |
The constructor is only meant to be called internally.
This takes the klass (class object) of a controller
and constructs a Builder ready to apply the make_resourceful
additions to the controller.
This method is only meant to be called internally.
Applies all the changes that have been declared
via the instance methods of this Builder
to the kontroller passed in to the constructor.
|
[
"The",
"constructor",
"is",
"only",
"meant",
"to",
"be",
"called",
"internally",
"."
] |
138455b3650917ffdf31dfee4ef9d4aff3f47b06
|
https://github.com/hcatlin/make_resourceful/blob/138455b3650917ffdf31dfee4ef9d4aff3f47b06/lib/resourceful/builder.rb#L40-L70
|
20,705
|
hcatlin/make_resourceful
|
lib/resourceful/builder.rb
|
Resourceful.Builder.belongs_to
|
def belongs_to(*parents)
options = parents.extract_options!
@parents = parents.map(&:to_s)
if options[:shallow]
options[:shallow] = options[:shallow].to_s
raise ArgumentError, ":shallow needs the name of a parent resource" unless @parents.include? options[:shallow]
@shallow_parent = options[:shallow]
end
end
|
ruby
|
def belongs_to(*parents)
options = parents.extract_options!
@parents = parents.map(&:to_s)
if options[:shallow]
options[:shallow] = options[:shallow].to_s
raise ArgumentError, ":shallow needs the name of a parent resource" unless @parents.include? options[:shallow]
@shallow_parent = options[:shallow]
end
end
|
[
"def",
"belongs_to",
"(",
"*",
"parents",
")",
"options",
"=",
"parents",
".",
"extract_options!",
"@parents",
"=",
"parents",
".",
"map",
"(",
":to_s",
")",
"if",
"options",
"[",
":shallow",
"]",
"options",
"[",
":shallow",
"]",
"=",
"options",
"[",
":shallow",
"]",
".",
"to_s",
"raise",
"ArgumentError",
",",
"\":shallow needs the name of a parent resource\"",
"unless",
"@parents",
".",
"include?",
"options",
"[",
":shallow",
"]",
"@shallow_parent",
"=",
"options",
"[",
":shallow",
"]",
"end",
"end"
] |
Specifies parent resources for the current resource.
Each of these parents will be loaded automatically
if the proper id parameter is given.
For example,
# cake_controller.rb
belongs_to :baker, :customer
Then on GET /bakers/12/cakes,
params[:baker_id] #=> 12
parent? #=> true
parent_name #=> "baker"
parent_model #=> Baker
parent_object #=> Baker.find(12)
current_objects #=> Baker.find(12).cakes
|
[
"Specifies",
"parent",
"resources",
"for",
"the",
"current",
"resource",
".",
"Each",
"of",
"these",
"parents",
"will",
"be",
"loaded",
"automatically",
"if",
"the",
"proper",
"id",
"parameter",
"is",
"given",
".",
"For",
"example"
] |
138455b3650917ffdf31dfee4ef9d4aff3f47b06
|
https://github.com/hcatlin/make_resourceful/blob/138455b3650917ffdf31dfee4ef9d4aff3f47b06/lib/resourceful/builder.rb#L364-L372
|
20,706
|
raw1z/amistad
|
lib/amistad/mongo_friend_model.rb
|
Amistad.MongoFriendModel.blocked?
|
def blocked?(user)
(blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).include?(user.id) or user.blocked_pending_inverse_friend_ids.include?(self.id)
end
|
ruby
|
def blocked?(user)
(blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).include?(user.id) or user.blocked_pending_inverse_friend_ids.include?(self.id)
end
|
[
"def",
"blocked?",
"(",
"user",
")",
"(",
"blocked_friend_ids",
"+",
"blocked_inverse_friend_ids",
"+",
"blocked_pending_inverse_friend_ids",
")",
".",
"include?",
"(",
"user",
".",
"id",
")",
"or",
"user",
".",
"blocked_pending_inverse_friend_ids",
".",
"include?",
"(",
"self",
".",
"id",
")",
"end"
] |
checks if a user is blocked
|
[
"checks",
"if",
"a",
"user",
"is",
"blocked"
] |
3da822509611450e4777f6571ea0967fd5bf6602
|
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/mongo_friend_model.rb#L146-L148
|
20,707
|
raw1z/amistad
|
lib/amistad/mongo_friend_model.rb
|
Amistad.MongoFriendModel.friendshiped_with?
|
def friendshiped_with?(user)
(friend_ids + inverse_friend_ids + pending_friend_ids + pending_inverse_friend_ids + blocked_friend_ids).include?(user.id)
end
|
ruby
|
def friendshiped_with?(user)
(friend_ids + inverse_friend_ids + pending_friend_ids + pending_inverse_friend_ids + blocked_friend_ids).include?(user.id)
end
|
[
"def",
"friendshiped_with?",
"(",
"user",
")",
"(",
"friend_ids",
"+",
"inverse_friend_ids",
"+",
"pending_friend_ids",
"+",
"pending_inverse_friend_ids",
"+",
"blocked_friend_ids",
")",
".",
"include?",
"(",
"user",
".",
"id",
")",
"end"
] |
check if any friendship exists with another user
|
[
"check",
"if",
"any",
"friendship",
"exists",
"with",
"another",
"user"
] |
3da822509611450e4777f6571ea0967fd5bf6602
|
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/mongo_friend_model.rb#L151-L153
|
20,708
|
raw1z/amistad
|
lib/amistad/mongo_friend_model.rb
|
Amistad.MongoFriendModel.delete_all_friendships
|
def delete_all_friendships
friend_ids.clear
inverse_friend_ids.clear
pending_friend_ids.clear
pending_inverse_friend_ids.clear
blocked_friend_ids.clear
blocked_inverse_friend_ids.clear
blocked_pending_friend_ids.clear
blocked_pending_inverse_friend_ids.clear
self.save
end
|
ruby
|
def delete_all_friendships
friend_ids.clear
inverse_friend_ids.clear
pending_friend_ids.clear
pending_inverse_friend_ids.clear
blocked_friend_ids.clear
blocked_inverse_friend_ids.clear
blocked_pending_friend_ids.clear
blocked_pending_inverse_friend_ids.clear
self.save
end
|
[
"def",
"delete_all_friendships",
"friend_ids",
".",
"clear",
"inverse_friend_ids",
".",
"clear",
"pending_friend_ids",
".",
"clear",
"pending_inverse_friend_ids",
".",
"clear",
"blocked_friend_ids",
".",
"clear",
"blocked_inverse_friend_ids",
".",
"clear",
"blocked_pending_friend_ids",
".",
"clear",
"blocked_pending_inverse_friend_ids",
".",
"clear",
"self",
".",
"save",
"end"
] |
deletes all the friendships
|
[
"deletes",
"all",
"the",
"friendships"
] |
3da822509611450e4777f6571ea0967fd5bf6602
|
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/mongo_friend_model.rb#L156-L166
|
20,709
|
hcatlin/make_resourceful
|
spec/spec_helper.rb
|
RailsMocks.ControllerMethods.render
|
def render(options=nil, deprecated_status_or_extra_options=nil, &block)
if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
deprecated_status_or_extra_options = {}
end
unless block_given?
if @template.respond_to?(:finder)
(class << @template.finder; self; end).class_eval do
define_method :file_exists? do; true; end
end
else
(class << @template; self; end).class_eval do
define_method :file_exists? do; true; end
end
end
(class << @template; self; end).class_eval do
define_method :render_file do |*args|
@first_render ||= args[0] unless args[0] =~ /^layouts/
@_first_render ||= args[0] unless args[0] =~ /^layouts/
end
define_method :_pick_template do |*args|
@_first_render ||= args[0] unless args[0] =~ /^layouts/
PickedTemplate.new
end
end
end
super(options, deprecated_status_or_extra_options, &block)
end
|
ruby
|
def render(options=nil, deprecated_status_or_extra_options=nil, &block)
if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
deprecated_status_or_extra_options = {}
end
unless block_given?
if @template.respond_to?(:finder)
(class << @template.finder; self; end).class_eval do
define_method :file_exists? do; true; end
end
else
(class << @template; self; end).class_eval do
define_method :file_exists? do; true; end
end
end
(class << @template; self; end).class_eval do
define_method :render_file do |*args|
@first_render ||= args[0] unless args[0] =~ /^layouts/
@_first_render ||= args[0] unless args[0] =~ /^layouts/
end
define_method :_pick_template do |*args|
@_first_render ||= args[0] unless args[0] =~ /^layouts/
PickedTemplate.new
end
end
end
super(options, deprecated_status_or_extra_options, &block)
end
|
[
"def",
"render",
"(",
"options",
"=",
"nil",
",",
"deprecated_status_or_extra_options",
"=",
"nil",
",",
"&",
"block",
")",
"if",
"::",
"Rails",
"::",
"VERSION",
"::",
"STRING",
">=",
"'2.0.0'",
"&&",
"deprecated_status_or_extra_options",
".",
"nil?",
"deprecated_status_or_extra_options",
"=",
"{",
"}",
"end",
"unless",
"block_given?",
"if",
"@template",
".",
"respond_to?",
"(",
":finder",
")",
"(",
"class",
"<<",
"@template",
".",
"finder",
";",
"self",
";",
"end",
")",
".",
"class_eval",
"do",
"define_method",
":file_exists?",
"do",
";",
"true",
";",
"end",
"end",
"else",
"(",
"class",
"<<",
"@template",
";",
"self",
";",
"end",
")",
".",
"class_eval",
"do",
"define_method",
":file_exists?",
"do",
";",
"true",
";",
"end",
"end",
"end",
"(",
"class",
"<<",
"@template",
";",
"self",
";",
"end",
")",
".",
"class_eval",
"do",
"define_method",
":render_file",
"do",
"|",
"*",
"args",
"|",
"@first_render",
"||=",
"args",
"[",
"0",
"]",
"unless",
"args",
"[",
"0",
"]",
"=~",
"/",
"/",
"@_first_render",
"||=",
"args",
"[",
"0",
"]",
"unless",
"args",
"[",
"0",
"]",
"=~",
"/",
"/",
"end",
"define_method",
":_pick_template",
"do",
"|",
"*",
"args",
"|",
"@_first_render",
"||=",
"args",
"[",
"0",
"]",
"unless",
"args",
"[",
"0",
"]",
"=~",
"/",
"/",
"PickedTemplate",
".",
"new",
"end",
"end",
"end",
"super",
"(",
"options",
",",
"deprecated_status_or_extra_options",
",",
"block",
")",
"end"
] |
From rspec-rails ControllerExampleGroup
|
[
"From",
"rspec",
"-",
"rails",
"ControllerExampleGroup"
] |
138455b3650917ffdf31dfee4ef9d4aff3f47b06
|
https://github.com/hcatlin/make_resourceful/blob/138455b3650917ffdf31dfee4ef9d4aff3f47b06/spec/spec_helper.rb#L227-L256
|
20,710
|
raw1z/amistad
|
lib/amistad/active_record_friend_model.rb
|
Amistad.ActiveRecordFriendModel.unblock
|
def unblock(user)
friendship = find_any_friendship_with(user)
return false if friendship.nil? || !friendship.can_unblock?(self)
friendship.update_attribute(:blocker, nil)
end
|
ruby
|
def unblock(user)
friendship = find_any_friendship_with(user)
return false if friendship.nil? || !friendship.can_unblock?(self)
friendship.update_attribute(:blocker, nil)
end
|
[
"def",
"unblock",
"(",
"user",
")",
"friendship",
"=",
"find_any_friendship_with",
"(",
"user",
")",
"return",
"false",
"if",
"friendship",
".",
"nil?",
"||",
"!",
"friendship",
".",
"can_unblock?",
"(",
"self",
")",
"friendship",
".",
"update_attribute",
"(",
":blocker",
",",
"nil",
")",
"end"
] |
unblocks a friendship
|
[
"unblocks",
"a",
"friendship"
] |
3da822509611450e4777f6571ea0967fd5bf6602
|
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/active_record_friend_model.rb#L84-L88
|
20,711
|
raw1z/amistad
|
lib/amistad/active_record_friend_model.rb
|
Amistad.ActiveRecordFriendModel.find_any_friendship_with
|
def find_any_friendship_with(user)
friendship = Amistad.friendship_class.where(:friendable_id => self.id, :friend_id => user.id).first
if friendship.nil?
friendship = Amistad.friendship_class.where(:friendable_id => user.id, :friend_id => self.id).first
end
friendship
end
|
ruby
|
def find_any_friendship_with(user)
friendship = Amistad.friendship_class.where(:friendable_id => self.id, :friend_id => user.id).first
if friendship.nil?
friendship = Amistad.friendship_class.where(:friendable_id => user.id, :friend_id => self.id).first
end
friendship
end
|
[
"def",
"find_any_friendship_with",
"(",
"user",
")",
"friendship",
"=",
"Amistad",
".",
"friendship_class",
".",
"where",
"(",
":friendable_id",
"=>",
"self",
".",
"id",
",",
":friend_id",
"=>",
"user",
".",
"id",
")",
".",
"first",
"if",
"friendship",
".",
"nil?",
"friendship",
"=",
"Amistad",
".",
"friendship_class",
".",
"where",
"(",
":friendable_id",
"=>",
"user",
".",
"id",
",",
":friend_id",
"=>",
"self",
".",
"id",
")",
".",
"first",
"end",
"friendship",
"end"
] |
returns friendship with given user or nil
|
[
"returns",
"friendship",
"with",
"given",
"user",
"or",
"nil"
] |
3da822509611450e4777f6571ea0967fd5bf6602
|
https://github.com/raw1z/amistad/blob/3da822509611450e4777f6571ea0967fd5bf6602/lib/amistad/active_record_friend_model.rb#L136-L142
|
20,712
|
Swirrl/tripod
|
lib/tripod/extensions/module.rb
|
Tripod::Extensions.Module.re_define_method
|
def re_define_method(name, &block)
undef_method(name) if method_defined?(name)
define_method(name, &block)
end
|
ruby
|
def re_define_method(name, &block)
undef_method(name) if method_defined?(name)
define_method(name, &block)
end
|
[
"def",
"re_define_method",
"(",
"name",
",",
"&",
"block",
")",
"undef_method",
"(",
"name",
")",
"if",
"method_defined?",
"(",
"name",
")",
"define_method",
"(",
"name",
",",
"block",
")",
"end"
] |
Redefine the method. Will undef the method if it exists or simply
just define it.
@example Redefine the method.
Object.re_define_method("exists?") do
self
end
@param [ String, Symbol ] name The name of the method.
@param [ Proc ] block The method body.
@return [ Method ] The new method.
|
[
"Redefine",
"the",
"method",
".",
"Will",
"undef",
"the",
"method",
"if",
"it",
"exists",
"or",
"simply",
"just",
"define",
"it",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/extensions/module.rb#L17-L20
|
20,713
|
Swirrl/tripod
|
lib/tripod/rdf_type.rb
|
Tripod::RdfType.ClassMethods.rdf_type
|
def rdf_type(new_rdf_type)
self._RDF_TYPE = RDF::URI.new(new_rdf_type.to_s)
field :rdf_type, RDF.type, :multivalued => true, :is_uri => true # things can have more than 1 type and often do
end
|
ruby
|
def rdf_type(new_rdf_type)
self._RDF_TYPE = RDF::URI.new(new_rdf_type.to_s)
field :rdf_type, RDF.type, :multivalued => true, :is_uri => true # things can have more than 1 type and often do
end
|
[
"def",
"rdf_type",
"(",
"new_rdf_type",
")",
"self",
".",
"_RDF_TYPE",
"=",
"RDF",
"::",
"URI",
".",
"new",
"(",
"new_rdf_type",
".",
"to_s",
")",
"field",
":rdf_type",
",",
"RDF",
".",
"type",
",",
":multivalued",
"=>",
"true",
",",
":is_uri",
"=>",
"true",
"# things can have more than 1 type and often do",
"end"
] |
makes a "field" on this model called rdf_type
and sets a class level _RDF_TYPE variable with the rdf_type passed in.
|
[
"makes",
"a",
"field",
"on",
"this",
"model",
"called",
"rdf_type",
"and",
"sets",
"a",
"class",
"level",
"_RDF_TYPE",
"variable",
"with",
"the",
"rdf_type",
"passed",
"in",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/rdf_type.rb#L16-L19
|
20,714
|
xi-livecode/xi
|
lib/xi/pattern.rb
|
Xi.Pattern.p
|
def p(*delta, **metadata)
delta = delta.compact.empty? ? @delta : delta
Pattern.new(@source, delta: delta, size: @size, **@metadata.merge(metadata))
end
|
ruby
|
def p(*delta, **metadata)
delta = delta.compact.empty? ? @delta : delta
Pattern.new(@source, delta: delta, size: @size, **@metadata.merge(metadata))
end
|
[
"def",
"p",
"(",
"*",
"delta",
",",
"**",
"metadata",
")",
"delta",
"=",
"delta",
".",
"compact",
".",
"empty?",
"?",
"@delta",
":",
"delta",
"Pattern",
".",
"new",
"(",
"@source",
",",
"delta",
":",
"delta",
",",
"size",
":",
"@size",
",",
"**",
"@metadata",
".",
"merge",
"(",
"metadata",
")",
")",
"end"
] |
Returns a new Pattern with the same +source+, but with +delta+ overriden
and +metadata+ merged.
@param delta [Array<Numeric>, Pattern<Numeric>, Numeric]
@param metadata [Hash]
@return [Pattern]
|
[
"Returns",
"a",
"new",
"Pattern",
"with",
"the",
"same",
"+",
"source",
"+",
"but",
"with",
"+",
"delta",
"+",
"overriden",
"and",
"+",
"metadata",
"+",
"merged",
"."
] |
215dfb84899b3dd00f11089ae3eab0febf498e95
|
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L131-L134
|
20,715
|
xi-livecode/xi
|
lib/xi/pattern.rb
|
Xi.Pattern.each_event
|
def each_event(cycle=0)
return enum_for(__method__, cycle) unless block_given?
EventEnumerator.new(self, cycle).each { |v, s, d, i| yield v, s, d, i }
end
|
ruby
|
def each_event(cycle=0)
return enum_for(__method__, cycle) unless block_given?
EventEnumerator.new(self, cycle).each { |v, s, d, i| yield v, s, d, i }
end
|
[
"def",
"each_event",
"(",
"cycle",
"=",
"0",
")",
"return",
"enum_for",
"(",
"__method__",
",",
"cycle",
")",
"unless",
"block_given?",
"EventEnumerator",
".",
"new",
"(",
"self",
",",
"cycle",
")",
".",
"each",
"{",
"|",
"v",
",",
"s",
",",
"d",
",",
"i",
"|",
"yield",
"v",
",",
"s",
",",
"d",
",",
"i",
"}",
"end"
] |
Calls the given block once for each event, passing its value, start
position, duration and iteration as parameters.
+cycle+ can be any number, even if there is no event that starts exactly
at that moment. It will start from the next event.
If no block is given, an enumerator is returned instead.
Enumeration loops forever, and starts yielding events based on pattern's
delta and from the +cycle+ position, which is by default 0.
@example block yields value, start, duration and iteration
Pattern.new([1, 2], delta: 0.25).each_event.take(4)
# => [[1, 0.0, 0.25, 0],
# [2, 0.25, 0.25, 0],
# [1, 0.5, 0.25, 1],
# [2, 0.75, 0.25, 1]]
@example +cycle+ is used to start iterating from that moment in time
Pattern.new([:a, :b, :c], delta: 1/2).each_event(42).take(4)
# => [[:a, (42/1), (1/2), 28],
# [:b, (85/2), (1/2), 28],
# [:c, (43/1), (1/2), 28],
# [:a, (87/2), (1/2), 29]]
@example +cycle+ can also be a fractional number
Pattern.new([:a, :b, :c]).each_event(0.97).take(3)
# => [[:b, 1, 1, 0],
# [:c, 2, 1, 0],
# [:a, 3, 1, 1]]
@param cycle [Numeric]
@yield [v, s, d, i] value, start, duration and iteration
@return [Enumerator]
|
[
"Calls",
"the",
"given",
"block",
"once",
"for",
"each",
"event",
"passing",
"its",
"value",
"start",
"position",
"duration",
"and",
"iteration",
"as",
"parameters",
"."
] |
215dfb84899b3dd00f11089ae3eab0febf498e95
|
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L194-L197
|
20,716
|
xi-livecode/xi
|
lib/xi/pattern.rb
|
Xi.Pattern.each_delta
|
def each_delta(index=0)
return enum_for(__method__, index) unless block_given?
delta = @delta
if delta.is_a?(Array)
size = delta.size
return if size == 0
start = index.floor
i = start % size
loop do
yield delta[i]
i = (i + 1) % size
start += 1
end
elsif delta.is_a?(Pattern)
delta.each_event(index) { |v, _| yield v }
else
loop { yield delta }
end
end
|
ruby
|
def each_delta(index=0)
return enum_for(__method__, index) unless block_given?
delta = @delta
if delta.is_a?(Array)
size = delta.size
return if size == 0
start = index.floor
i = start % size
loop do
yield delta[i]
i = (i + 1) % size
start += 1
end
elsif delta.is_a?(Pattern)
delta.each_event(index) { |v, _| yield v }
else
loop { yield delta }
end
end
|
[
"def",
"each_delta",
"(",
"index",
"=",
"0",
")",
"return",
"enum_for",
"(",
"__method__",
",",
"index",
")",
"unless",
"block_given?",
"delta",
"=",
"@delta",
"if",
"delta",
".",
"is_a?",
"(",
"Array",
")",
"size",
"=",
"delta",
".",
"size",
"return",
"if",
"size",
"==",
"0",
"start",
"=",
"index",
".",
"floor",
"i",
"=",
"start",
"%",
"size",
"loop",
"do",
"yield",
"delta",
"[",
"i",
"]",
"i",
"=",
"(",
"i",
"+",
"1",
")",
"%",
"size",
"start",
"+=",
"1",
"end",
"elsif",
"delta",
".",
"is_a?",
"(",
"Pattern",
")",
"delta",
".",
"each_event",
"(",
"index",
")",
"{",
"|",
"v",
",",
"_",
"|",
"yield",
"v",
"}",
"else",
"loop",
"{",
"yield",
"delta",
"}",
"end",
"end"
] |
Calls the given block passing the delta of each value in pattern
This method is used internally by {#each_event} to calculate when each
event in pattern occurs in time. If no block is given, an Enumerator is
returned instead.
@param index [Numeric]
@yield [d] duration
@return [Enumerator]
|
[
"Calls",
"the",
"given",
"block",
"passing",
"the",
"delta",
"of",
"each",
"value",
"in",
"pattern"
] |
215dfb84899b3dd00f11089ae3eab0febf498e95
|
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L209-L230
|
20,717
|
xi-livecode/xi
|
lib/xi/pattern.rb
|
Xi.Pattern.each
|
def each
return enum_for(__method__) unless block_given?
each_event { |v, _, _, i|
break if i > 0
yield v
}
end
|
ruby
|
def each
return enum_for(__method__) unless block_given?
each_event { |v, _, _, i|
break if i > 0
yield v
}
end
|
[
"def",
"each",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"each_event",
"{",
"|",
"v",
",",
"_",
",",
"_",
",",
"i",
"|",
"break",
"if",
"i",
">",
"0",
"yield",
"v",
"}",
"end"
] |
Calls the given block once for each value in source
@example
Pattern.new([1, 2, 3]).each.to_a
# => [1, 2, 3]
@return [Enumerator]
@yield [Object] value
|
[
"Calls",
"the",
"given",
"block",
"once",
"for",
"each",
"value",
"in",
"source"
] |
215dfb84899b3dd00f11089ae3eab0febf498e95
|
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L241-L248
|
20,718
|
xi-livecode/xi
|
lib/xi/pattern.rb
|
Xi.Pattern.select
|
def select
return enum_for(__method__) unless block_given?
Pattern.new(self) do |y, d|
each_event do |v, s, ed, i|
y << v if yield(v, s, ed, i)
end
end
end
|
ruby
|
def select
return enum_for(__method__) unless block_given?
Pattern.new(self) do |y, d|
each_event do |v, s, ed, i|
y << v if yield(v, s, ed, i)
end
end
end
|
[
"def",
"select",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"Pattern",
".",
"new",
"(",
"self",
")",
"do",
"|",
"y",
",",
"d",
"|",
"each_event",
"do",
"|",
"v",
",",
"s",
",",
"ed",
",",
"i",
"|",
"y",
"<<",
"v",
"if",
"yield",
"(",
"v",
",",
"s",
",",
"ed",
",",
"i",
")",
"end",
"end",
"end"
] |
Returns a Pattern containing all events of +self+ for which +block+ is
true.
If no block is given, an Enumerator is returned.
@see Pattern#reject
@yield [v, s, d, i] value, start, duration and iteration
@yieldreturn [Boolean] whether value is selected
@return [Pattern]
|
[
"Returns",
"a",
"Pattern",
"containing",
"all",
"events",
"of",
"+",
"self",
"+",
"for",
"which",
"+",
"block",
"+",
"is",
"true",
"."
] |
215dfb84899b3dd00f11089ae3eab0febf498e95
|
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L318-L326
|
20,719
|
xi-livecode/xi
|
lib/xi/pattern.rb
|
Xi.Pattern.reject
|
def reject
return enum_for(__method__) unless block_given?
select { |v, s, d, i| !yield(v, s, d, i) }
end
|
ruby
|
def reject
return enum_for(__method__) unless block_given?
select { |v, s, d, i| !yield(v, s, d, i) }
end
|
[
"def",
"reject",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"select",
"{",
"|",
"v",
",",
"s",
",",
"d",
",",
"i",
"|",
"!",
"yield",
"(",
"v",
",",
"s",
",",
"d",
",",
"i",
")",
"}",
"end"
] |
Returns a Pattern containing all events of +self+ for which +block+
is false.
If no block is given, an Enumerator is returned.
@see Pattern#select
@yield [v, s, d, i] value, start, duration and iteration
@yieldreturn [Boolean] whether event is rejected
@return [Pattern]
|
[
"Returns",
"a",
"Pattern",
"containing",
"all",
"events",
"of",
"+",
"self",
"+",
"for",
"which",
"+",
"block",
"+",
"is",
"false",
"."
] |
215dfb84899b3dd00f11089ae3eab0febf498e95
|
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L340-L344
|
20,720
|
xi-livecode/xi
|
lib/xi/pattern.rb
|
Xi.Pattern.first
|
def first(n=nil, *args)
res = take(n || 1, *args)
n.nil? ? res.first : res
end
|
ruby
|
def first(n=nil, *args)
res = take(n || 1, *args)
n.nil? ? res.first : res
end
|
[
"def",
"first",
"(",
"n",
"=",
"nil",
",",
"*",
"args",
")",
"res",
"=",
"take",
"(",
"n",
"||",
"1",
",",
"args",
")",
"n",
".",
"nil?",
"?",
"res",
".",
"first",
":",
"res",
"end"
] |
Returns the first element, or the first +n+ elements, of the pattern.
If the pattern is empty, the first form returns nil, and the second form
returns an empty array.
@see #take
@param n [Integer]
@param args same arguments as {#take}
@return [Object, Array]
|
[
"Returns",
"the",
"first",
"element",
"or",
"the",
"first",
"+",
"n",
"+",
"elements",
"of",
"the",
"pattern",
"."
] |
215dfb84899b3dd00f11089ae3eab0febf498e95
|
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L387-L390
|
20,721
|
xi-livecode/xi
|
lib/xi/pattern.rb
|
Xi.Pattern.inspect
|
def inspect
ss = if @source.respond_to?(:join)
@source.map(&:inspect).join(', ')
elsif @source.is_a?(Proc)
"?proc"
else
@source.inspect
end
ms = @metadata.reject { |_, v| v.nil? }
ms.merge!(delta: delta) if delta != 1
ms = ms.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')
"P[#{ss}#{", #{ms}" unless ms.empty?}]"
end
|
ruby
|
def inspect
ss = if @source.respond_to?(:join)
@source.map(&:inspect).join(', ')
elsif @source.is_a?(Proc)
"?proc"
else
@source.inspect
end
ms = @metadata.reject { |_, v| v.nil? }
ms.merge!(delta: delta) if delta != 1
ms = ms.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')
"P[#{ss}#{", #{ms}" unless ms.empty?}]"
end
|
[
"def",
"inspect",
"ss",
"=",
"if",
"@source",
".",
"respond_to?",
"(",
":join",
")",
"@source",
".",
"map",
"(",
":inspect",
")",
".",
"join",
"(",
"', '",
")",
"elsif",
"@source",
".",
"is_a?",
"(",
"Proc",
")",
"\"?proc\"",
"else",
"@source",
".",
"inspect",
"end",
"ms",
"=",
"@metadata",
".",
"reject",
"{",
"|",
"_",
",",
"v",
"|",
"v",
".",
"nil?",
"}",
"ms",
".",
"merge!",
"(",
"delta",
":",
"delta",
")",
"if",
"delta",
"!=",
"1",
"ms",
"=",
"ms",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"\"#{k}: #{v.inspect}\"",
"}",
".",
"join",
"(",
"', '",
")",
"\"P[#{ss}#{\", #{ms}\" unless ms.empty?}]\"",
"end"
] |
Returns a string containing a human-readable representation
When source is not a Proc, this string can be evaluated to construct the
same instance.
@return [String]
|
[
"Returns",
"a",
"string",
"containing",
"a",
"human",
"-",
"readable",
"representation"
] |
215dfb84899b3dd00f11089ae3eab0febf498e95
|
https://github.com/xi-livecode/xi/blob/215dfb84899b3dd00f11089ae3eab0febf498e95/lib/xi/pattern.rb#L399-L413
|
20,722
|
Swirrl/tripod
|
lib/tripod/fields.rb
|
Tripod::Fields.ClassMethods.get_field
|
def get_field(name)
@fields ||= {}
field = fields[name]
raise Tripod::Errors::FieldNotPresent.new unless field
field
end
|
ruby
|
def get_field(name)
@fields ||= {}
field = fields[name]
raise Tripod::Errors::FieldNotPresent.new unless field
field
end
|
[
"def",
"get_field",
"(",
"name",
")",
"@fields",
"||=",
"{",
"}",
"field",
"=",
"fields",
"[",
"name",
"]",
"raise",
"Tripod",
"::",
"Errors",
"::",
"FieldNotPresent",
".",
"new",
"unless",
"field",
"field",
"end"
] |
Return the field object on a +Resource+ associated with the given name.
@example Get the field.
Person.get_field(:name)
@param [ Symbol ] name The name of the field.
|
[
"Return",
"the",
"field",
"object",
"on",
"a",
"+",
"Resource",
"+",
"associated",
"with",
"the",
"given",
"name",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L56-L61
|
20,723
|
Swirrl/tripod
|
lib/tripod/fields.rb
|
Tripod::Fields.ClassMethods.fields
|
def fields
tripod_superclasses.map { |c| c.instance_variable_get(:@fields) }.reduce do |acc,class_fields|
class_fields.merge(acc)
end
end
|
ruby
|
def fields
tripod_superclasses.map { |c| c.instance_variable_get(:@fields) }.reduce do |acc,class_fields|
class_fields.merge(acc)
end
end
|
[
"def",
"fields",
"tripod_superclasses",
".",
"map",
"{",
"|",
"c",
"|",
"c",
".",
"instance_variable_get",
"(",
":@fields",
")",
"}",
".",
"reduce",
"do",
"|",
"acc",
",",
"class_fields",
"|",
"class_fields",
".",
"merge",
"(",
"acc",
")",
"end",
"end"
] |
Return all of the fields on a +Resource+ in a manner that
respects Ruby's inheritance rules. i.e. subclass fields should
override superclass fields with the same
|
[
"Return",
"all",
"of",
"the",
"fields",
"on",
"a",
"+",
"Resource",
"+",
"in",
"a",
"manner",
"that",
"respects",
"Ruby",
"s",
"inheritance",
"rules",
".",
"i",
".",
"e",
".",
"subclass",
"fields",
"should",
"override",
"superclass",
"fields",
"with",
"the",
"same"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L66-L70
|
20,724
|
Swirrl/tripod
|
lib/tripod/fields.rb
|
Tripod::Fields.ClassMethods.add_field
|
def add_field(name, predicate, options = {})
# create a field object and store it in our hash
field = field_for(name, predicate, options)
@fields ||= {}
@fields[name] = field
# set up the accessors for the fields
create_accessors(name, name, options)
# create a URL validation if appropriate
# (format nabbed from https://gist.github.com/joshuap/948880)
validates(name, is_url: true) if field.is_uri?
field
end
|
ruby
|
def add_field(name, predicate, options = {})
# create a field object and store it in our hash
field = field_for(name, predicate, options)
@fields ||= {}
@fields[name] = field
# set up the accessors for the fields
create_accessors(name, name, options)
# create a URL validation if appropriate
# (format nabbed from https://gist.github.com/joshuap/948880)
validates(name, is_url: true) if field.is_uri?
field
end
|
[
"def",
"add_field",
"(",
"name",
",",
"predicate",
",",
"options",
"=",
"{",
"}",
")",
"# create a field object and store it in our hash",
"field",
"=",
"field_for",
"(",
"name",
",",
"predicate",
",",
"options",
")",
"@fields",
"||=",
"{",
"}",
"@fields",
"[",
"name",
"]",
"=",
"field",
"# set up the accessors for the fields",
"create_accessors",
"(",
"name",
",",
"name",
",",
"options",
")",
"# create a URL validation if appropriate",
"# (format nabbed from https://gist.github.com/joshuap/948880)",
"validates",
"(",
"name",
",",
"is_url",
":",
"true",
")",
"if",
"field",
".",
"is_uri?",
"field",
"end"
] |
Define a field attribute for the +Resource+.
@example Set the field.
Person.add_field(:name, 'http://myfield')
@param [ Symbol ] name The name of the field.
@param [ String, RDF::URI ] predicate The predicate for the field.
@param [ Hash ] options The hash of options.
|
[
"Define",
"a",
"field",
"attribute",
"for",
"the",
"+",
"Resource",
"+",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L86-L100
|
20,725
|
Swirrl/tripod
|
lib/tripod/fields.rb
|
Tripod::Fields.ClassMethods.create_accessors
|
def create_accessors(name, meth, options = {})
field = @fields[name]
create_field_getter(name, meth, field)
create_field_setter(name, meth, field)
create_field_check(name, meth, field)
# from dirty.rb
create_dirty_methods(name, meth)
end
|
ruby
|
def create_accessors(name, meth, options = {})
field = @fields[name]
create_field_getter(name, meth, field)
create_field_setter(name, meth, field)
create_field_check(name, meth, field)
# from dirty.rb
create_dirty_methods(name, meth)
end
|
[
"def",
"create_accessors",
"(",
"name",
",",
"meth",
",",
"options",
"=",
"{",
"}",
")",
"field",
"=",
"@fields",
"[",
"name",
"]",
"create_field_getter",
"(",
"name",
",",
"meth",
",",
"field",
")",
"create_field_setter",
"(",
"name",
",",
"meth",
",",
"field",
")",
"create_field_check",
"(",
"name",
",",
"meth",
",",
"field",
")",
"# from dirty.rb",
"create_dirty_methods",
"(",
"name",
",",
"meth",
")",
"end"
] |
Create the field accessors.
@example Generate the accessors.
Person.create_accessors(:name, "name")
person.name #=> returns the field
person.name = "" #=> sets the field
person.name? #=> Is the field present?
@param [ Symbol ] name The name of the field.
@param [ Symbol ] meth The name of the accessor.
@param [ Hash ] options The options.
|
[
"Create",
"the",
"field",
"accessors",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L113-L122
|
20,726
|
Swirrl/tripod
|
lib/tripod/fields.rb
|
Tripod::Fields.ClassMethods.create_field_getter
|
def create_field_getter(name, meth, field)
generated_methods.module_eval do
re_define_method(meth) do
read_attribute(name, field)
end
end
end
|
ruby
|
def create_field_getter(name, meth, field)
generated_methods.module_eval do
re_define_method(meth) do
read_attribute(name, field)
end
end
end
|
[
"def",
"create_field_getter",
"(",
"name",
",",
"meth",
",",
"field",
")",
"generated_methods",
".",
"module_eval",
"do",
"re_define_method",
"(",
"meth",
")",
"do",
"read_attribute",
"(",
"name",
",",
"field",
")",
"end",
"end",
"end"
] |
Create the getter method for the provided field.
@example Create the getter.
Model.create_field_getter("name", "name", field)
@param [ String ] name The name of the attribute.
@param [ String ] meth The name of the method.
@param [ Field ] field The field.
|
[
"Create",
"the",
"getter",
"method",
"for",
"the",
"provided",
"field",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L132-L138
|
20,727
|
Swirrl/tripod
|
lib/tripod/fields.rb
|
Tripod::Fields.ClassMethods.create_field_setter
|
def create_field_setter(name, meth, field)
generated_methods.module_eval do
re_define_method("#{meth}=") do |value|
write_attribute(name, value, field)
end
end
end
|
ruby
|
def create_field_setter(name, meth, field)
generated_methods.module_eval do
re_define_method("#{meth}=") do |value|
write_attribute(name, value, field)
end
end
end
|
[
"def",
"create_field_setter",
"(",
"name",
",",
"meth",
",",
"field",
")",
"generated_methods",
".",
"module_eval",
"do",
"re_define_method",
"(",
"\"#{meth}=\"",
")",
"do",
"|",
"value",
"|",
"write_attribute",
"(",
"name",
",",
"value",
",",
"field",
")",
"end",
"end",
"end"
] |
Create the setter method for the provided field.
@example Create the setter.
Model.create_field_setter("name", "name")
@param [ String ] name The name of the attribute.
@param [ String ] meth The name of the method.
@param [ Field ] field The field.
|
[
"Create",
"the",
"setter",
"method",
"for",
"the",
"provided",
"field",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L148-L154
|
20,728
|
Swirrl/tripod
|
lib/tripod/fields.rb
|
Tripod::Fields.ClassMethods.create_field_check
|
def create_field_check(name, meth, field)
generated_methods.module_eval do
re_define_method("#{meth}?") do
attr = read_attribute(name, field)
attr == true || attr.present?
end
end
end
|
ruby
|
def create_field_check(name, meth, field)
generated_methods.module_eval do
re_define_method("#{meth}?") do
attr = read_attribute(name, field)
attr == true || attr.present?
end
end
end
|
[
"def",
"create_field_check",
"(",
"name",
",",
"meth",
",",
"field",
")",
"generated_methods",
".",
"module_eval",
"do",
"re_define_method",
"(",
"\"#{meth}?\"",
")",
"do",
"attr",
"=",
"read_attribute",
"(",
"name",
",",
"field",
")",
"attr",
"==",
"true",
"||",
"attr",
".",
"present?",
"end",
"end",
"end"
] |
Create the check method for the provided field.
@example Create the check.
Model.create_field_check("name", "name")
@param [ String ] name The name of the attribute.
@param [ String ] meth The name of the method.
|
[
"Create",
"the",
"check",
"method",
"for",
"the",
"provided",
"field",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L163-L170
|
20,729
|
Swirrl/tripod
|
lib/tripod/fields.rb
|
Tripod::Fields.ClassMethods.field_for
|
def field_for(name, predicate, options)
Tripod::Fields::Standard.new(name, predicate, options)
end
|
ruby
|
def field_for(name, predicate, options)
Tripod::Fields::Standard.new(name, predicate, options)
end
|
[
"def",
"field_for",
"(",
"name",
",",
"predicate",
",",
"options",
")",
"Tripod",
"::",
"Fields",
"::",
"Standard",
".",
"new",
"(",
"name",
",",
"predicate",
",",
"options",
")",
"end"
] |
instantiates and returns a new standard field
|
[
"instantiates",
"and",
"returns",
"a",
"new",
"standard",
"field"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/fields.rb#L188-L190
|
20,730
|
Swirrl/tripod
|
lib/tripod/finders.rb
|
Tripod::Finders.ClassMethods.describe_uris
|
def describe_uris(uris)
graph = RDF::Graph.new
if uris.length > 0
uris_sparql_str = uris.map{ |u| "<#{u.to_s}>" }.join(" ")
# Do a big describe statement, and read the results into an in-memory repo
ntriples_string = Tripod::SparqlClient::Query.query("CONSTRUCT { ?s ?p ?o } WHERE { VALUES ?s { #{uris_sparql_str} }. ?s ?p ?o . }", Tripod.ntriples_header_str)
graph = _rdf_graph_from_ntriples_string(ntriples_string, graph)
end
graph
end
|
ruby
|
def describe_uris(uris)
graph = RDF::Graph.new
if uris.length > 0
uris_sparql_str = uris.map{ |u| "<#{u.to_s}>" }.join(" ")
# Do a big describe statement, and read the results into an in-memory repo
ntriples_string = Tripod::SparqlClient::Query.query("CONSTRUCT { ?s ?p ?o } WHERE { VALUES ?s { #{uris_sparql_str} }. ?s ?p ?o . }", Tripod.ntriples_header_str)
graph = _rdf_graph_from_ntriples_string(ntriples_string, graph)
end
graph
end
|
[
"def",
"describe_uris",
"(",
"uris",
")",
"graph",
"=",
"RDF",
"::",
"Graph",
".",
"new",
"if",
"uris",
".",
"length",
">",
"0",
"uris_sparql_str",
"=",
"uris",
".",
"map",
"{",
"|",
"u",
"|",
"\"<#{u.to_s}>\"",
"}",
".",
"join",
"(",
"\" \"",
")",
"# Do a big describe statement, and read the results into an in-memory repo",
"ntriples_string",
"=",
"Tripod",
"::",
"SparqlClient",
"::",
"Query",
".",
"query",
"(",
"\"CONSTRUCT { ?s ?p ?o } WHERE { VALUES ?s { #{uris_sparql_str} }. ?s ?p ?o . }\"",
",",
"Tripod",
".",
"ntriples_header_str",
")",
"graph",
"=",
"_rdf_graph_from_ntriples_string",
"(",
"ntriples_string",
",",
"graph",
")",
"end",
"graph",
"end"
] |
returns a graph of triples which describe the uris passed in.
|
[
"returns",
"a",
"graph",
"of",
"triples",
"which",
"describe",
"the",
"uris",
"passed",
"in",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L105-L117
|
20,731
|
Swirrl/tripod
|
lib/tripod/finders.rb
|
Tripod::Finders.ClassMethods._rdf_graph_from_ntriples_string
|
def _rdf_graph_from_ntriples_string(ntriples_string, graph=nil)
graph ||= RDF::Graph.new
RDF::Reader.for(:ntriples).new(ntriples_string) do |reader|
reader.each_statement do |statement|
graph << statement
end
end
graph
end
|
ruby
|
def _rdf_graph_from_ntriples_string(ntriples_string, graph=nil)
graph ||= RDF::Graph.new
RDF::Reader.for(:ntriples).new(ntriples_string) do |reader|
reader.each_statement do |statement|
graph << statement
end
end
graph
end
|
[
"def",
"_rdf_graph_from_ntriples_string",
"(",
"ntriples_string",
",",
"graph",
"=",
"nil",
")",
"graph",
"||=",
"RDF",
"::",
"Graph",
".",
"new",
"RDF",
"::",
"Reader",
".",
"for",
"(",
":ntriples",
")",
".",
"new",
"(",
"ntriples_string",
")",
"do",
"|",
"reader",
"|",
"reader",
".",
"each_statement",
"do",
"|",
"statement",
"|",
"graph",
"<<",
"statement",
"end",
"end",
"graph",
"end"
] |
given a string of ntriples data, populate an RDF graph.
If you pass a graph in, it will add to that one.
|
[
"given",
"a",
"string",
"of",
"ntriples",
"data",
"populate",
"an",
"RDF",
"graph",
".",
"If",
"you",
"pass",
"a",
"graph",
"in",
"it",
"will",
"add",
"to",
"that",
"one",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L140-L148
|
20,732
|
Swirrl/tripod
|
lib/tripod/finders.rb
|
Tripod::Finders.ClassMethods._graph_of_triples_from_construct_or_describe
|
def _graph_of_triples_from_construct_or_describe(construct_query)
ntriples_str = Tripod::SparqlClient::Query.query(construct_query, Tripod.ntriples_header_str)
_rdf_graph_from_ntriples_string(ntriples_str, graph=nil)
end
|
ruby
|
def _graph_of_triples_from_construct_or_describe(construct_query)
ntriples_str = Tripod::SparqlClient::Query.query(construct_query, Tripod.ntriples_header_str)
_rdf_graph_from_ntriples_string(ntriples_str, graph=nil)
end
|
[
"def",
"_graph_of_triples_from_construct_or_describe",
"(",
"construct_query",
")",
"ntriples_str",
"=",
"Tripod",
"::",
"SparqlClient",
"::",
"Query",
".",
"query",
"(",
"construct_query",
",",
"Tripod",
".",
"ntriples_header_str",
")",
"_rdf_graph_from_ntriples_string",
"(",
"ntriples_str",
",",
"graph",
"=",
"nil",
")",
"end"
] |
given a construct or describe query, return a graph of triples.
|
[
"given",
"a",
"construct",
"or",
"describe",
"query",
"return",
"a",
"graph",
"of",
"triples",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L151-L154
|
20,733
|
Swirrl/tripod
|
lib/tripod/finders.rb
|
Tripod::Finders.ClassMethods._create_and_hydrate_resources_from_sparql
|
def _create_and_hydrate_resources_from_sparql(select_sparql, opts={})
# TODO: Optimization?: if return_graph option is false, then don't do this next line?
uris_and_graphs = _select_uris_and_graphs(select_sparql, :uri_variable => opts[:uri_variable], :graph_variable => opts[:graph_variable])
#there are no resources if there are no uris and graphs
if uris_and_graphs.empty?
[]
else
construct_query = _construct_query_for_uris_and_graphs(uris_and_graphs)
graph = _graph_of_triples_from_construct_or_describe(construct_query)
_resources_from_graph(graph, uris_and_graphs)
end
end
|
ruby
|
def _create_and_hydrate_resources_from_sparql(select_sparql, opts={})
# TODO: Optimization?: if return_graph option is false, then don't do this next line?
uris_and_graphs = _select_uris_and_graphs(select_sparql, :uri_variable => opts[:uri_variable], :graph_variable => opts[:graph_variable])
#there are no resources if there are no uris and graphs
if uris_and_graphs.empty?
[]
else
construct_query = _construct_query_for_uris_and_graphs(uris_and_graphs)
graph = _graph_of_triples_from_construct_or_describe(construct_query)
_resources_from_graph(graph, uris_and_graphs)
end
end
|
[
"def",
"_create_and_hydrate_resources_from_sparql",
"(",
"select_sparql",
",",
"opts",
"=",
"{",
"}",
")",
"# TODO: Optimization?: if return_graph option is false, then don't do this next line?",
"uris_and_graphs",
"=",
"_select_uris_and_graphs",
"(",
"select_sparql",
",",
":uri_variable",
"=>",
"opts",
"[",
":uri_variable",
"]",
",",
":graph_variable",
"=>",
"opts",
"[",
":graph_variable",
"]",
")",
"#there are no resources if there are no uris and graphs",
"if",
"uris_and_graphs",
".",
"empty?",
"[",
"]",
"else",
"construct_query",
"=",
"_construct_query_for_uris_and_graphs",
"(",
"uris_and_graphs",
")",
"graph",
"=",
"_graph_of_triples_from_construct_or_describe",
"(",
"construct_query",
")",
"_resources_from_graph",
"(",
"graph",
",",
"uris_and_graphs",
")",
"end",
"end"
] |
Given a select query, perform a DESCRIBE query to get a graph of data from which we
create and hydrate a collection of resources.
@option options [ String ] uri_variable The name of the uri variable in the query, if not 'uri'
@option options [ String ] graph_variable The name of the uri variable in the query, if not 'graph'
|
[
"Given",
"a",
"select",
"query",
"perform",
"a",
"DESCRIBE",
"query",
"to",
"get",
"a",
"graph",
"of",
"data",
"from",
"which",
"we",
"create",
"and",
"hydrate",
"a",
"collection",
"of",
"resources",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L161-L173
|
20,734
|
Swirrl/tripod
|
lib/tripod/finders.rb
|
Tripod::Finders.ClassMethods._construct_query_for_uris_and_graphs
|
def _construct_query_for_uris_and_graphs(uris_and_graphs)
value_pairs = uris_and_graphs.map do |(uri, graph)|
u = RDF::URI.new(uri).to_base
g = graph ? RDF::URI.new(graph).to_base : 'UNDEF'
"(#{u} #{g})"
end
query = "CONSTRUCT { ?uri ?p ?o . #{ self.all_triples_construct("?uri") }} WHERE { GRAPH ?g { ?uri ?p ?o . #{ self.all_triples_where("?uri") } VALUES (?uri ?g) { #{ value_pairs.join(' ') } } } }"
end
|
ruby
|
def _construct_query_for_uris_and_graphs(uris_and_graphs)
value_pairs = uris_and_graphs.map do |(uri, graph)|
u = RDF::URI.new(uri).to_base
g = graph ? RDF::URI.new(graph).to_base : 'UNDEF'
"(#{u} #{g})"
end
query = "CONSTRUCT { ?uri ?p ?o . #{ self.all_triples_construct("?uri") }} WHERE { GRAPH ?g { ?uri ?p ?o . #{ self.all_triples_where("?uri") } VALUES (?uri ?g) { #{ value_pairs.join(' ') } } } }"
end
|
[
"def",
"_construct_query_for_uris_and_graphs",
"(",
"uris_and_graphs",
")",
"value_pairs",
"=",
"uris_and_graphs",
".",
"map",
"do",
"|",
"(",
"uri",
",",
"graph",
")",
"|",
"u",
"=",
"RDF",
"::",
"URI",
".",
"new",
"(",
"uri",
")",
".",
"to_base",
"g",
"=",
"graph",
"?",
"RDF",
"::",
"URI",
".",
"new",
"(",
"graph",
")",
".",
"to_base",
":",
"'UNDEF'",
"\"(#{u} #{g})\"",
"end",
"query",
"=",
"\"CONSTRUCT { ?uri ?p ?o . #{ self.all_triples_construct(\"?uri\") }} WHERE { GRAPH ?g { ?uri ?p ?o . #{ self.all_triples_where(\"?uri\") } VALUES (?uri ?g) { #{ value_pairs.join(' ') } } } }\"",
"end"
] |
Generate a CONSTRUCT query for the given uri and graph pairs.
|
[
"Generate",
"a",
"CONSTRUCT",
"query",
"for",
"the",
"given",
"uri",
"and",
"graph",
"pairs",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L196-L203
|
20,735
|
Swirrl/tripod
|
lib/tripod/finders.rb
|
Tripod::Finders.ClassMethods._raw_describe_select_results
|
def _raw_describe_select_results(select_sparql, opts={})
accept_header = opts[:accept_header] || Tripod.ntriples_header_str
query = _describe_query_for_select(select_sparql, :uri_variable => opts[:uri_variable])
Tripod::SparqlClient::Query.query(query, accept_header)
end
|
ruby
|
def _raw_describe_select_results(select_sparql, opts={})
accept_header = opts[:accept_header] || Tripod.ntriples_header_str
query = _describe_query_for_select(select_sparql, :uri_variable => opts[:uri_variable])
Tripod::SparqlClient::Query.query(query, accept_header)
end
|
[
"def",
"_raw_describe_select_results",
"(",
"select_sparql",
",",
"opts",
"=",
"{",
"}",
")",
"accept_header",
"=",
"opts",
"[",
":accept_header",
"]",
"||",
"Tripod",
".",
"ntriples_header_str",
"query",
"=",
"_describe_query_for_select",
"(",
"select_sparql",
",",
":uri_variable",
"=>",
"opts",
"[",
":uri_variable",
"]",
")",
"Tripod",
"::",
"SparqlClient",
"::",
"Query",
".",
"query",
"(",
"query",
",",
"accept_header",
")",
"end"
] |
For a select query, get a raw serialisation of the DESCRIPTION of the resources from the database.
@option options [ String ] uri_variable The name of the uri variable in the query, if not 'uri'
@option options [ String ] accept_header The http accept header (default application/n-triples)
|
[
"For",
"a",
"select",
"query",
"get",
"a",
"raw",
"serialisation",
"of",
"the",
"DESCRIPTION",
"of",
"the",
"resources",
"from",
"the",
"database",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/finders.rb#L209-L213
|
20,736
|
Swirrl/tripod
|
lib/tripod/resource_collection.rb
|
Tripod.ResourceCollection.to_nt
|
def to_nt
time_serialization('nt') do
if @criteria
@criteria.serialize(:return_graph => @return_graph, :accept_header => Tripod.ntriples_header_str)
elsif @sparql_query_str && @resource_class
# run the query as a describe.
@resource_class._raw_describe_select_results(@sparql_query_str, :accept_header => Tripod.ntriples_header_str)
else
# for n-triples we can just concatenate them
nt = ""
resources.each do |resource|
nt += resource.to_nt
end
nt
end
end
end
|
ruby
|
def to_nt
time_serialization('nt') do
if @criteria
@criteria.serialize(:return_graph => @return_graph, :accept_header => Tripod.ntriples_header_str)
elsif @sparql_query_str && @resource_class
# run the query as a describe.
@resource_class._raw_describe_select_results(@sparql_query_str, :accept_header => Tripod.ntriples_header_str)
else
# for n-triples we can just concatenate them
nt = ""
resources.each do |resource|
nt += resource.to_nt
end
nt
end
end
end
|
[
"def",
"to_nt",
"time_serialization",
"(",
"'nt'",
")",
"do",
"if",
"@criteria",
"@criteria",
".",
"serialize",
"(",
":return_graph",
"=>",
"@return_graph",
",",
":accept_header",
"=>",
"Tripod",
".",
"ntriples_header_str",
")",
"elsif",
"@sparql_query_str",
"&&",
"@resource_class",
"# run the query as a describe.",
"@resource_class",
".",
"_raw_describe_select_results",
"(",
"@sparql_query_str",
",",
":accept_header",
"=>",
"Tripod",
".",
"ntriples_header_str",
")",
"else",
"# for n-triples we can just concatenate them",
"nt",
"=",
"\"\"",
"resources",
".",
"each",
"do",
"|",
"resource",
"|",
"nt",
"+=",
"resource",
".",
"to_nt",
"end",
"nt",
"end",
"end",
"end"
] |
for n-triples we can just concatenate them
|
[
"for",
"n",
"-",
"triples",
"we",
"can",
"just",
"concatenate",
"them"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/resource_collection.rb#L53-L69
|
20,737
|
Swirrl/tripod
|
lib/tripod/criteria/execution.rb
|
Tripod.CriteriaExecution.resources
|
def resources(opts={})
Tripod::ResourceCollection.new(
self.resource_class._resources_from_sparql(self.as_query(opts)),
# pass in the criteria that was used to generate this collection, as well as whether the user specified return graph
:return_graph => (opts.has_key?(:return_graph) ? opts[:return_graph] : true),
:criteria => self
)
end
|
ruby
|
def resources(opts={})
Tripod::ResourceCollection.new(
self.resource_class._resources_from_sparql(self.as_query(opts)),
# pass in the criteria that was used to generate this collection, as well as whether the user specified return graph
:return_graph => (opts.has_key?(:return_graph) ? opts[:return_graph] : true),
:criteria => self
)
end
|
[
"def",
"resources",
"(",
"opts",
"=",
"{",
"}",
")",
"Tripod",
"::",
"ResourceCollection",
".",
"new",
"(",
"self",
".",
"resource_class",
".",
"_resources_from_sparql",
"(",
"self",
".",
"as_query",
"(",
"opts",
")",
")",
",",
"# pass in the criteria that was used to generate this collection, as well as whether the user specified return graph",
":return_graph",
"=>",
"(",
"opts",
".",
"has_key?",
"(",
":return_graph",
")",
"?",
"opts",
"[",
":return_graph",
"]",
":",
"true",
")",
",",
":criteria",
"=>",
"self",
")",
"end"
] |
Execute the query and return a +ResourceCollection+ of all hydrated resources
+ResourceCollection+ is an +Enumerable+, Array-like object.
@option options [ String ] return_graph Indicates whether to return the graph as one of the variables.
|
[
"Execute",
"the",
"query",
"and",
"return",
"a",
"+",
"ResourceCollection",
"+",
"of",
"all",
"hydrated",
"resources",
"+",
"ResourceCollection",
"+",
"is",
"an",
"+",
"Enumerable",
"+",
"Array",
"-",
"like",
"object",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria/execution.rb#L13-L20
|
20,738
|
Swirrl/tripod
|
lib/tripod/criteria/execution.rb
|
Tripod.CriteriaExecution.first
|
def first(opts={})
sq = Tripod::SparqlQuery.new(self.as_query(opts))
first_sparql = sq.as_first_query_str
self.resource_class._resources_from_sparql(first_sparql).first
end
|
ruby
|
def first(opts={})
sq = Tripod::SparqlQuery.new(self.as_query(opts))
first_sparql = sq.as_first_query_str
self.resource_class._resources_from_sparql(first_sparql).first
end
|
[
"def",
"first",
"(",
"opts",
"=",
"{",
"}",
")",
"sq",
"=",
"Tripod",
"::",
"SparqlQuery",
".",
"new",
"(",
"self",
".",
"as_query",
"(",
"opts",
")",
")",
"first_sparql",
"=",
"sq",
".",
"as_first_query_str",
"self",
".",
"resource_class",
".",
"_resources_from_sparql",
"(",
"first_sparql",
")",
".",
"first",
"end"
] |
Execute the query and return the first result as a hydrated resource
@option options [ String ] return_graph Indicates whether to return the graph as one of the variables.
|
[
"Execute",
"the",
"query",
"and",
"return",
"the",
"first",
"result",
"as",
"a",
"hydrated",
"resource"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria/execution.rb#L34-L38
|
20,739
|
Swirrl/tripod
|
lib/tripod/criteria/execution.rb
|
Tripod.CriteriaExecution.count
|
def count(opts={})
sq = Tripod::SparqlQuery.new(self.as_query(opts))
count_sparql = sq.as_count_query_str
result = Tripod::SparqlClient::Query.select(count_sparql)
if result.length > 0
result[0]["tripod_count_var"]["value"].to_i
else
return 0
end
end
|
ruby
|
def count(opts={})
sq = Tripod::SparqlQuery.new(self.as_query(opts))
count_sparql = sq.as_count_query_str
result = Tripod::SparqlClient::Query.select(count_sparql)
if result.length > 0
result[0]["tripod_count_var"]["value"].to_i
else
return 0
end
end
|
[
"def",
"count",
"(",
"opts",
"=",
"{",
"}",
")",
"sq",
"=",
"Tripod",
"::",
"SparqlQuery",
".",
"new",
"(",
"self",
".",
"as_query",
"(",
"opts",
")",
")",
"count_sparql",
"=",
"sq",
".",
"as_count_query_str",
"result",
"=",
"Tripod",
"::",
"SparqlClient",
"::",
"Query",
".",
"select",
"(",
"count_sparql",
")",
"if",
"result",
".",
"length",
">",
"0",
"result",
"[",
"0",
"]",
"[",
"\"tripod_count_var\"",
"]",
"[",
"\"value\"",
"]",
".",
"to_i",
"else",
"return",
"0",
"end",
"end"
] |
Return how many records the current criteria would return
@option options [ String ] return_graph Indicates whether to return the graph as one of the variables.
|
[
"Return",
"how",
"many",
"records",
"the",
"current",
"criteria",
"would",
"return"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria/execution.rb#L43-L53
|
20,740
|
Swirrl/tripod
|
lib/tripod/criteria/execution.rb
|
Tripod.CriteriaExecution.as_query
|
def as_query(opts={})
Tripod.logger.debug("TRIPOD: building select query for criteria...")
return_graph = opts.has_key?(:return_graph) ? opts[:return_graph] : true
Tripod.logger.debug("TRIPOD: with return_graph: #{return_graph.inspect}")
select_query = "SELECT DISTINCT ?uri "
if graph_lambdas.empty?
if return_graph
# if we are returning the graph, select it as a variable, and include either the <graph> or ?graph in the where clause
if graph_uri
select_query += "(<#{graph_uri}> as ?graph) WHERE { GRAPH <#{graph_uri}> { "
else
select_query += "?graph WHERE { GRAPH ?graph { "
end
else
select_query += "WHERE { "
# if we're not returning the graph, only restrict by the <graph> if there's one set at class level
select_query += "GRAPH <#{graph_uri}> { " if graph_uri
end
select_query += self.query_where_clauses.join(" . ")
select_query += " } "
select_query += "} " if return_graph || graph_uri # close the graph clause
else
# whip through the graph lambdas and add into the query
# we have multiple graphs so the above does not apply
select_query += "WHERE { "
graph_lambdas.each do |lambda_item|
select_query += "GRAPH ?g { "
select_query += lambda_item.call
select_query += " } "
end
select_query += self.query_where_clauses.join(" . ")
select_query += " } "
end
select_query += self.extra_clauses.join(" ")
select_query += [order_clause, limit_clause, offset_clause].join(" ")
select_query.strip
end
|
ruby
|
def as_query(opts={})
Tripod.logger.debug("TRIPOD: building select query for criteria...")
return_graph = opts.has_key?(:return_graph) ? opts[:return_graph] : true
Tripod.logger.debug("TRIPOD: with return_graph: #{return_graph.inspect}")
select_query = "SELECT DISTINCT ?uri "
if graph_lambdas.empty?
if return_graph
# if we are returning the graph, select it as a variable, and include either the <graph> or ?graph in the where clause
if graph_uri
select_query += "(<#{graph_uri}> as ?graph) WHERE { GRAPH <#{graph_uri}> { "
else
select_query += "?graph WHERE { GRAPH ?graph { "
end
else
select_query += "WHERE { "
# if we're not returning the graph, only restrict by the <graph> if there's one set at class level
select_query += "GRAPH <#{graph_uri}> { " if graph_uri
end
select_query += self.query_where_clauses.join(" . ")
select_query += " } "
select_query += "} " if return_graph || graph_uri # close the graph clause
else
# whip through the graph lambdas and add into the query
# we have multiple graphs so the above does not apply
select_query += "WHERE { "
graph_lambdas.each do |lambda_item|
select_query += "GRAPH ?g { "
select_query += lambda_item.call
select_query += " } "
end
select_query += self.query_where_clauses.join(" . ")
select_query += " } "
end
select_query += self.extra_clauses.join(" ")
select_query += [order_clause, limit_clause, offset_clause].join(" ")
select_query.strip
end
|
[
"def",
"as_query",
"(",
"opts",
"=",
"{",
"}",
")",
"Tripod",
".",
"logger",
".",
"debug",
"(",
"\"TRIPOD: building select query for criteria...\"",
")",
"return_graph",
"=",
"opts",
".",
"has_key?",
"(",
":return_graph",
")",
"?",
"opts",
"[",
":return_graph",
"]",
":",
"true",
"Tripod",
".",
"logger",
".",
"debug",
"(",
"\"TRIPOD: with return_graph: #{return_graph.inspect}\"",
")",
"select_query",
"=",
"\"SELECT DISTINCT ?uri \"",
"if",
"graph_lambdas",
".",
"empty?",
"if",
"return_graph",
"# if we are returning the graph, select it as a variable, and include either the <graph> or ?graph in the where clause",
"if",
"graph_uri",
"select_query",
"+=",
"\"(<#{graph_uri}> as ?graph) WHERE { GRAPH <#{graph_uri}> { \"",
"else",
"select_query",
"+=",
"\"?graph WHERE { GRAPH ?graph { \"",
"end",
"else",
"select_query",
"+=",
"\"WHERE { \"",
"# if we're not returning the graph, only restrict by the <graph> if there's one set at class level",
"select_query",
"+=",
"\"GRAPH <#{graph_uri}> { \"",
"if",
"graph_uri",
"end",
"select_query",
"+=",
"self",
".",
"query_where_clauses",
".",
"join",
"(",
"\" . \"",
")",
"select_query",
"+=",
"\" } \"",
"select_query",
"+=",
"\"} \"",
"if",
"return_graph",
"||",
"graph_uri",
"# close the graph clause",
"else",
"# whip through the graph lambdas and add into the query",
"# we have multiple graphs so the above does not apply",
"select_query",
"+=",
"\"WHERE { \"",
"graph_lambdas",
".",
"each",
"do",
"|",
"lambda_item",
"|",
"select_query",
"+=",
"\"GRAPH ?g { \"",
"select_query",
"+=",
"lambda_item",
".",
"call",
"select_query",
"+=",
"\" } \"",
"end",
"select_query",
"+=",
"self",
".",
"query_where_clauses",
".",
"join",
"(",
"\" . \"",
")",
"select_query",
"+=",
"\" } \"",
"end",
"select_query",
"+=",
"self",
".",
"extra_clauses",
".",
"join",
"(",
"\" \"",
")",
"select_query",
"+=",
"[",
"order_clause",
",",
"limit_clause",
",",
"offset_clause",
"]",
".",
"join",
"(",
"\" \"",
")",
"select_query",
".",
"strip",
"end"
] |
turn this criteria into a query
|
[
"turn",
"this",
"criteria",
"into",
"a",
"query"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria/execution.rb#L56-L104
|
20,741
|
Swirrl/tripod
|
lib/tripod/repository.rb
|
Tripod::Repository.ClassMethods.add_data_to_repository
|
def add_data_to_repository(graph, repo=nil)
repo ||= RDF::Repository.new()
graph.each_statement do |statement|
repo << statement
end
repo
end
|
ruby
|
def add_data_to_repository(graph, repo=nil)
repo ||= RDF::Repository.new()
graph.each_statement do |statement|
repo << statement
end
repo
end
|
[
"def",
"add_data_to_repository",
"(",
"graph",
",",
"repo",
"=",
"nil",
")",
"repo",
"||=",
"RDF",
"::",
"Repository",
".",
"new",
"(",
")",
"graph",
".",
"each_statement",
"do",
"|",
"statement",
"|",
"repo",
"<<",
"statement",
"end",
"repo",
"end"
] |
for triples in the graph passed in, add them to the passed in repository obj, and return the repository objects
if no repository passed, make a new one.
|
[
"for",
"triples",
"in",
"the",
"graph",
"passed",
"in",
"add",
"them",
"to",
"the",
"passed",
"in",
"repository",
"obj",
"and",
"return",
"the",
"repository",
"objects",
"if",
"no",
"repository",
"passed",
"make",
"a",
"new",
"one",
"."
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/repository.rb#L75-L84
|
20,742
|
Swirrl/tripod
|
lib/tripod/criteria.rb
|
Tripod.Criteria.graph
|
def graph(graph_uri, &block)
if block_given?
self.graph_lambdas ||= []
self.graph_lambdas << block
self
else
self.graph_uri = graph_uri.to_s
self
end
end
|
ruby
|
def graph(graph_uri, &block)
if block_given?
self.graph_lambdas ||= []
self.graph_lambdas << block
self
else
self.graph_uri = graph_uri.to_s
self
end
end
|
[
"def",
"graph",
"(",
"graph_uri",
",",
"&",
"block",
")",
"if",
"block_given?",
"self",
".",
"graph_lambdas",
"||=",
"[",
"]",
"self",
".",
"graph_lambdas",
"<<",
"block",
"self",
"else",
"self",
".",
"graph_uri",
"=",
"graph_uri",
".",
"to_s",
"self",
"end",
"end"
] |
Restrict this query to the graph uri passed in
You may also pass a block to an unbound graph, ?g
then chain a where clause to the criteria returned to bind ?g
@example .graph(RDF::URI.new('http://graphoid')
@example .graph('http://graphoid')
@example .graph(nil) { "?s ?p ?o" }.where("?uri ?p ?g")
@param [ String, RDF::URI ] The graph uri
@param [ Block ] A string to be executed within an unbound graph, ?g
@return [ Tripod::Criteria ] A criteria object
|
[
"Restrict",
"this",
"query",
"to",
"the",
"graph",
"uri",
"passed",
"in",
"You",
"may",
"also",
"pass",
"a",
"block",
"to",
"an",
"unbound",
"graph",
"?g",
"then",
"chain",
"a",
"where",
"clause",
"to",
"the",
"criteria",
"returned",
"to",
"bind",
"?g"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/criteria.rb#L101-L111
|
20,743
|
Swirrl/tripod
|
lib/tripod/links.rb
|
Tripod::Links.ClassMethods.linked_from_for
|
def linked_from_for(name, incoming_field_name, options)
Tripod::Links::LinkedFrom.new(name, incoming_field_name, options)
end
|
ruby
|
def linked_from_for(name, incoming_field_name, options)
Tripod::Links::LinkedFrom.new(name, incoming_field_name, options)
end
|
[
"def",
"linked_from_for",
"(",
"name",
",",
"incoming_field_name",
",",
"options",
")",
"Tripod",
"::",
"Links",
"::",
"LinkedFrom",
".",
"new",
"(",
"name",
",",
"incoming_field_name",
",",
"options",
")",
"end"
] |
instantiates and returns a new LinkedFrom
|
[
"instantiates",
"and",
"returns",
"a",
"new",
"LinkedFrom"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/links.rb#L164-L166
|
20,744
|
Swirrl/tripod
|
lib/tripod/links.rb
|
Tripod::Links.ClassMethods.linked_to_for
|
def linked_to_for(name, predicate, options)
Tripod::Links::LinkedTo.new(name, predicate, options)
end
|
ruby
|
def linked_to_for(name, predicate, options)
Tripod::Links::LinkedTo.new(name, predicate, options)
end
|
[
"def",
"linked_to_for",
"(",
"name",
",",
"predicate",
",",
"options",
")",
"Tripod",
"::",
"Links",
"::",
"LinkedTo",
".",
"new",
"(",
"name",
",",
"predicate",
",",
"options",
")",
"end"
] |
instantiates and returns a new LinkTo
|
[
"instantiates",
"and",
"returns",
"a",
"new",
"LinkTo"
] |
00bb42c67b68e5c6843b9883cd5c69a318f3b72b
|
https://github.com/Swirrl/tripod/blob/00bb42c67b68e5c6843b9883cd5c69a318f3b72b/lib/tripod/links.rb#L169-L171
|
20,745
|
story-branch/story_branch
|
lib/story_branch/main.rb
|
StoryBranch.Main.validate_branch_name
|
def validate_branch_name(name, id)
if GitUtils.branch_for_story_exists? id
prompt.error("An existing branch has the same story id: #{id}")
return false
end
if GitUtils.existing_branch? name
prompt.error('This name is very similar to an existing branch. Avoid confusion and use a more unique name.')
return false
end
true
end
|
ruby
|
def validate_branch_name(name, id)
if GitUtils.branch_for_story_exists? id
prompt.error("An existing branch has the same story id: #{id}")
return false
end
if GitUtils.existing_branch? name
prompt.error('This name is very similar to an existing branch. Avoid confusion and use a more unique name.')
return false
end
true
end
|
[
"def",
"validate_branch_name",
"(",
"name",
",",
"id",
")",
"if",
"GitUtils",
".",
"branch_for_story_exists?",
"id",
"prompt",
".",
"error",
"(",
"\"An existing branch has the same story id: #{id}\"",
")",
"return",
"false",
"end",
"if",
"GitUtils",
".",
"existing_branch?",
"name",
"prompt",
".",
"error",
"(",
"'This name is very similar to an existing branch. Avoid confusion and use a more unique name.'",
")",
"return",
"false",
"end",
"true",
"end"
] |
Branch name validation
|
[
"Branch",
"name",
"validation"
] |
2ad2aa94f89b5a278c4f4ea32db7bccfb1ab05d7
|
https://github.com/story-branch/story_branch/blob/2ad2aa94f89b5a278c4f4ea32db7bccfb1ab05d7/lib/story_branch/main.rb#L178-L188
|
20,746
|
bernerdschaefer/akephalos
|
lib/akephalos/node.rb
|
Akephalos.Node.value
|
def value
case tag_name
when "select"
if self[:multiple]
selected_options.map { |option| option.value }
else
selected_option = @_node.selected_options.first
selected_option ? Node.new(selected_option).value : nil
end
when "option"
self[:value] || text
when "textarea"
@_node.getText
else
self[:value]
end
end
|
ruby
|
def value
case tag_name
when "select"
if self[:multiple]
selected_options.map { |option| option.value }
else
selected_option = @_node.selected_options.first
selected_option ? Node.new(selected_option).value : nil
end
when "option"
self[:value] || text
when "textarea"
@_node.getText
else
self[:value]
end
end
|
[
"def",
"value",
"case",
"tag_name",
"when",
"\"select\"",
"if",
"self",
"[",
":multiple",
"]",
"selected_options",
".",
"map",
"{",
"|",
"option",
"|",
"option",
".",
"value",
"}",
"else",
"selected_option",
"=",
"@_node",
".",
"selected_options",
".",
"first",
"selected_option",
"?",
"Node",
".",
"new",
"(",
"selected_option",
")",
".",
"value",
":",
"nil",
"end",
"when",
"\"option\"",
"self",
"[",
":value",
"]",
"||",
"text",
"when",
"\"textarea\"",
"@_node",
".",
"getText",
"else",
"self",
"[",
":value",
"]",
"end",
"end"
] |
Return the value of a form element. If the element is a select box and
has "multiple" declared as an attribute, then all selected options will
be returned as an array.
@return [String, Array<String>] the node's value
|
[
"Return",
"the",
"value",
"of",
"a",
"form",
"element",
".",
"If",
"the",
"element",
"is",
"a",
"select",
"box",
"and",
"has",
"multiple",
"declared",
"as",
"an",
"attribute",
"then",
"all",
"selected",
"options",
"will",
"be",
"returned",
"as",
"an",
"array",
"."
] |
80103301ebe1609b90de04a8e4f6092def818585
|
https://github.com/bernerdschaefer/akephalos/blob/80103301ebe1609b90de04a8e4f6092def818585/lib/akephalos/node.rb#L40-L56
|
20,747
|
bernerdschaefer/akephalos
|
lib/akephalos/node.rb
|
Akephalos.Node.value=
|
def value=(value)
case tag_name
when "textarea"
@_node.setText("")
type(value)
when "input"
if file_input?
@_node.setValueAttribute(value)
else
@_node.setValueAttribute("")
type(value)
end
end
end
|
ruby
|
def value=(value)
case tag_name
when "textarea"
@_node.setText("")
type(value)
when "input"
if file_input?
@_node.setValueAttribute(value)
else
@_node.setValueAttribute("")
type(value)
end
end
end
|
[
"def",
"value",
"=",
"(",
"value",
")",
"case",
"tag_name",
"when",
"\"textarea\"",
"@_node",
".",
"setText",
"(",
"\"\"",
")",
"type",
"(",
"value",
")",
"when",
"\"input\"",
"if",
"file_input?",
"@_node",
".",
"setValueAttribute",
"(",
"value",
")",
"else",
"@_node",
".",
"setValueAttribute",
"(",
"\"\"",
")",
"type",
"(",
"value",
")",
"end",
"end",
"end"
] |
Set the value of the form input.
@param [String] value
|
[
"Set",
"the",
"value",
"of",
"the",
"form",
"input",
"."
] |
80103301ebe1609b90de04a8e4f6092def818585
|
https://github.com/bernerdschaefer/akephalos/blob/80103301ebe1609b90de04a8e4f6092def818585/lib/akephalos/node.rb#L61-L74
|
20,748
|
bernerdschaefer/akephalos
|
lib/akephalos/node.rb
|
Akephalos.Node.click
|
def click
@_node.click
@_node.getPage.getEnclosingWindow.getJobManager.waitForJobs(1000)
@_node.getPage.getEnclosingWindow.getJobManager.waitForJobsStartingBefore(1000)
end
|
ruby
|
def click
@_node.click
@_node.getPage.getEnclosingWindow.getJobManager.waitForJobs(1000)
@_node.getPage.getEnclosingWindow.getJobManager.waitForJobsStartingBefore(1000)
end
|
[
"def",
"click",
"@_node",
".",
"click",
"@_node",
".",
"getPage",
".",
"getEnclosingWindow",
".",
"getJobManager",
".",
"waitForJobs",
"(",
"1000",
")",
"@_node",
".",
"getPage",
".",
"getEnclosingWindow",
".",
"getJobManager",
".",
"waitForJobsStartingBefore",
"(",
"1000",
")",
"end"
] |
Click the node and then wait for any triggered JavaScript callbacks to
fire.
|
[
"Click",
"the",
"node",
"and",
"then",
"wait",
"for",
"any",
"triggered",
"JavaScript",
"callbacks",
"to",
"fire",
"."
] |
80103301ebe1609b90de04a8e4f6092def818585
|
https://github.com/bernerdschaefer/akephalos/blob/80103301ebe1609b90de04a8e4f6092def818585/lib/akephalos/node.rb#L150-L154
|
20,749
|
phcdevworks/multi-tenancy-devise
|
app/controllers/mtdevise/accounts_controller.rb
|
Mtdevise.AccountsController.create
|
def create
account = if user_signed_in?
Mtdevise::Account.create(account_params)
else
Mtdevise::Account.create_with_owner(account_params)
end
@account = account
if account.valid?
flash[:success] = "Your account has been successfully created."
if user_signed_in?
account.owner = current_user
account.users << current_user
account.save
redirect_to mtdevise.accounts_path
else
sign_in account.owner
redirect_to mtdevise.root_url(:subdomain => account.subdomain)
end
else
flash[:error] = "Sorry, your account could not be created."
render :new
end
end
|
ruby
|
def create
account = if user_signed_in?
Mtdevise::Account.create(account_params)
else
Mtdevise::Account.create_with_owner(account_params)
end
@account = account
if account.valid?
flash[:success] = "Your account has been successfully created."
if user_signed_in?
account.owner = current_user
account.users << current_user
account.save
redirect_to mtdevise.accounts_path
else
sign_in account.owner
redirect_to mtdevise.root_url(:subdomain => account.subdomain)
end
else
flash[:error] = "Sorry, your account could not be created."
render :new
end
end
|
[
"def",
"create",
"account",
"=",
"if",
"user_signed_in?",
"Mtdevise",
"::",
"Account",
".",
"create",
"(",
"account_params",
")",
"else",
"Mtdevise",
"::",
"Account",
".",
"create_with_owner",
"(",
"account_params",
")",
"end",
"@account",
"=",
"account",
"if",
"account",
".",
"valid?",
"flash",
"[",
":success",
"]",
"=",
"\"Your account has been successfully created.\"",
"if",
"user_signed_in?",
"account",
".",
"owner",
"=",
"current_user",
"account",
".",
"users",
"<<",
"current_user",
"account",
".",
"save",
"redirect_to",
"mtdevise",
".",
"accounts_path",
"else",
"sign_in",
"account",
".",
"owner",
"redirect_to",
"mtdevise",
".",
"root_url",
"(",
":subdomain",
"=>",
"account",
".",
"subdomain",
")",
"end",
"else",
"flash",
"[",
":error",
"]",
"=",
"\"Sorry, your account could not be created.\"",
"render",
":new",
"end",
"end"
] |
Accounts Create action
|
[
"Accounts",
"Create",
"action"
] |
e0a6e4582a8f415539ab598863c5e4cde2cde2cd
|
https://github.com/phcdevworks/multi-tenancy-devise/blob/e0a6e4582a8f415539ab598863c5e4cde2cde2cd/app/controllers/mtdevise/accounts_controller.rb#L23-L50
|
20,750
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_ws_api_version
|
def get_ws_api_version
# remove everything down to host:port
host_url = @api_url.split('/api')
@http.set_url(host_url[0])
begin
# get the api version
response = @http.get('/api')
response[1]
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
ensure
# reset the url
@http.set_url(@api_url)
end
|
ruby
|
def get_ws_api_version
# remove everything down to host:port
host_url = @api_url.split('/api')
@http.set_url(host_url[0])
begin
# get the api version
response = @http.get('/api')
response[1]
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
ensure
# reset the url
@http.set_url(@api_url)
end
|
[
"def",
"get_ws_api_version",
"# remove everything down to host:port",
"host_url",
"=",
"@api_url",
".",
"split",
"(",
"'/api'",
")",
"@http",
".",
"set_url",
"(",
"host_url",
"[",
"0",
"]",
")",
"begin",
"# get the api version",
"response",
"=",
"@http",
".",
"get",
"(",
"'/api'",
")",
"response",
"[",
"1",
"]",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"ensure",
"# reset the url",
"@http",
".",
"set_url",
"(",
"@api_url",
")",
"end"
] |
Get the 3PAR WS API version.
==== Returns
WSAPI version hash
|
[
"Get",
"the",
"3PAR",
"WS",
"API",
"version",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L133-L148
|
20,751
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.create_flash_cache
|
def create_flash_cache(size_in_gib, mode = nil)
begin
@flash_cache.create_flash_cache(size_in_gib, mode)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def create_flash_cache(size_in_gib, mode = nil)
begin
@flash_cache.create_flash_cache(size_in_gib, mode)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"create_flash_cache",
"(",
"size_in_gib",
",",
"mode",
"=",
"nil",
")",
"begin",
"@flash_cache",
".",
"create_flash_cache",
"(",
"size_in_gib",
",",
"mode",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Creates a new FlashCache
==== Attributes
* size_in_gib - Specifies the node pair size of the Flash Cache on the system
type size_in_gib: Integer
* mode - Values supported Simulator: 1, Real: 2 (default)
type mode: Integer
==== Raises
* Hpe3parSdk::HTTPBadRequest
- NO_SPACE - Not enough space is available for the operation.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_EXCEEDS_RANGE - A JSON input object contains a name-value pair with a numeric value that exceeds the expected range. Flash Cache exceeds the expected range. The HTTP ref member contains the name.
* Hpe3parSdk::HTTPConflict
- EXISTENT_FLASH_CACHE - The Flash Cache already exists.
* Hpe3parSdk::HTTPForbidden
- FLASH_CACHE_NOT_SUPPORTED - Flash Cache is not supported.
* Hpe3parSdk::HTTPBadRequest
- INV_FLASH_CACHE_SIZE - Invalid Flash Cache size. The size must be a multiple of 16 G.
|
[
"Creates",
"a",
"new",
"FlashCache"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L186-L194
|
20,752
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_flash_cache
|
def get_flash_cache
begin
@flash_cache.get_flash_cache
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_flash_cache
begin
@flash_cache.get_flash_cache
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_flash_cache",
"begin",
"@flash_cache",
".",
"get_flash_cache",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Get Flash Cache information
==== Returns
FlashCache - Details of the specified flash cache
|
[
"Get",
"Flash",
"Cache",
"information"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L201-L208
|
20,753
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.delete_flash_cache
|
def delete_flash_cache
begin
@flash_cache.delete_flash_cache
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def delete_flash_cache
begin
@flash_cache.delete_flash_cache
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"delete_flash_cache",
"begin",
"@flash_cache",
".",
"delete_flash_cache",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Deletes an existing Flash Cache
==== Raises
* Hpe3parSdk::HTTPForbidden
- FLASH_CACHE_IS_BEING_REMOVED - Unable to delete the Flash Cache, the Flash Cache is being removed.
* Hpe3parSdk::HTTPForbidden
- FLASH_CACHE_NOT_SUPPORTED - Flash Cache is not supported on this system.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_FLASH_CACHE - The Flash Cache does not exist.
|
[
"Deletes",
"an",
"existing",
"Flash",
"Cache"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L220-L227
|
20,754
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_overall_system_capacity
|
def get_overall_system_capacity
begin
response = @http.get('/capacity')
response[1]
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_overall_system_capacity
begin
response = @http.get('/capacity')
response[1]
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_overall_system_capacity",
"begin",
"response",
"=",
"@http",
".",
"get",
"(",
"'/capacity'",
")",
"response",
"[",
"1",
"]",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets the overall system capacity for the 3PAR server.
==== Returns
Hash of system capacity information
capacity = {
"allCapacity"=> { # Overall system capacity
# includes FC, NL, SSD
# device types
"totalMiB"=>20054016, # Total system capacity
# in MiB
"allocated"=>{ # Allocated space info
"totalAllocatedMiB"=>12535808, # Total allocated
# capacity
"volumes"=> { # Volume capacity info
"totalVolumesMiB"=>10919936, # Total capacity
# allocated to volumes
"nonCPGsMiB"=> 0, # Total non-CPG capacity
"nonCPGUserMiB"=> 0, # The capacity allocated
# to non-CPG user space
"nonCPGSnapshotMiB"=>0, # The capacity allocated
# to non-CPG snapshot
# volumes
"nonCPGAdminMiB"=> 0, # The capacity allocated
# to non-CPG
# administrative volumes
"CPGsMiB"=>10919936, # Total capacity
# allocated to CPGs
"CPGUserMiB"=>7205538, # User CPG space
"CPGUserUsedMiB"=>7092550, # The CPG allocated to
# user space that is
# in use
"CPGUserUnusedMiB"=>112988, # The CPG allocated to
# user space that is not
# in use
"CPGSnapshotMiB"=>2411870, # Snapshot CPG space
"CPGSnapshotUsedMiB"=>210256, # CPG allocated to
# snapshot that is in use
"CPGSnapshotUnusedMiB"=>2201614, # CPG allocated to
# snapshot space that is
# not in use
"CPGAdminMiB"=>1302528, # Administrative volume
# CPG space
"CPGAdminUsedMiB"=> 115200, # The CPG allocated to
# administrative space
# that is in use
"CPGAdminUnusedMiB"=>1187328, # The CPG allocated to
# administrative space
# that is not in use
"unmappedMiB"=>0 # Allocated volume space
# that is unmapped
},
"system"=> { # System capacity info
"totalSystemMiB"=> 1615872, # System space capacity
"internalMiB"=>780288, # The system capacity
# allocated to internal
# resources
"spareMiB"=> 835584, # Total spare capacity
"spareUsedMiB"=> 0, # The system capacity
# allocated to spare resources
# in use
"spareUnusedMiB"=> 835584 # The system capacity
# allocated to spare resources
# that are unused
}
},
"freeMiB"=> 7518208, # Free capacity
"freeInitializedMiB"=> 7518208, # Free initialized capacity
"freeUninitializedMiB"=> 0, # Free uninitialized capacity
"unavailableCapacityMiB"=> 0, # Unavailable capacity in MiB
"failedCapacityMiB"=> 0 # Failed capacity in MiB
},
"FCCapacity"=> { # System capacity from FC devices only
... # Same structure as above
},
"NLCapacity"=> { # System capacity from NL devices only
... # Same structure as above
},
"SSDCapacity"=> { # System capacity from SSD devices only
... # Same structure as above
}
}
|
[
"Gets",
"the",
"overall",
"system",
"capacity",
"for",
"the",
"3PAR",
"server",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L328-L336
|
20,755
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_all_tasks
|
def get_all_tasks
begin
@task.get_all_tasks
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_all_tasks
begin
@task.get_all_tasks
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_all_tasks",
"begin",
"@task",
".",
"get_all_tasks",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Get the list of all 3PAR Tasks
==== Returns
Array of Task
|
[
"Get",
"the",
"list",
"of",
"all",
"3PAR",
"Tasks"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L357-L364
|
20,756
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_task
|
def get_task(task_id)
begin
@task.get_task(task_id)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_task(task_id)
begin
@task.get_task(task_id)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_task",
"(",
"task_id",
")",
"begin",
"@task",
".",
"get_task",
"(",
"task_id",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Get the status of a 3PAR Task
==== Attributes
* task_id - the task id
type task_id: Integer
==== Returns
Task
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_BELOW_RANGE - Bad Request Task ID must be a positive value.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_EXCEEDS_RANGE - Bad Request Task ID is too large.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_TASK - Task with the specified Task ID does not exist.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_WRONG_TYPE - Task ID is not an integer.
|
[
"Get",
"the",
"status",
"of",
"a",
"3PAR",
"Task"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L387-L394
|
20,757
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.create_vlun
|
def create_vlun(volume_name, lun = nil, host_name = nil, port_pos = nil, no_vcn = false, override_lower_priority = false, auto = false)
begin
@vlun.create_vlun(volume_name, host_name, lun, port_pos, no_vcn, override_lower_priority, auto)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def create_vlun(volume_name, lun = nil, host_name = nil, port_pos = nil, no_vcn = false, override_lower_priority = false, auto = false)
begin
@vlun.create_vlun(volume_name, host_name, lun, port_pos, no_vcn, override_lower_priority, auto)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"create_vlun",
"(",
"volume_name",
",",
"lun",
"=",
"nil",
",",
"host_name",
"=",
"nil",
",",
"port_pos",
"=",
"nil",
",",
"no_vcn",
"=",
"false",
",",
"override_lower_priority",
"=",
"false",
",",
"auto",
"=",
"false",
")",
"begin",
"@vlun",
".",
"create_vlun",
"(",
"volume_name",
",",
"host_name",
",",
"lun",
",",
"port_pos",
",",
"no_vcn",
",",
"override_lower_priority",
",",
"auto",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Creates a new VLUN.
When creating a VLUN, the volumeName is required. The lun member is
not required if auto is set to True.
Either hostname or portPos (or both in the case of matched sets) is
also required. The noVcn and overrideLowerPriority members are
optional.
* volume_name: Name of the volume to be exported
type volume_name: String
* lun: LUN id
type lun: Integer
* host_name: Name of the host which the volume is to be exported.
type host_name: String
* port_pos: System port of VLUN exported to. It includes node number, slot number, and card port number
type port_pos: Hash
port_pos = {'node'=> 1, # System node (0-7)
'slot'=> 2, # PCI bus slot in the node (0-5)
'port'=> 1} # Port number on the FC card (0-4)
* no_vcn: A VLUN change notification (VCN) not be issued after export (-novcn).
type no_vcn: Boolean
* override_lower_priority: Existing lower priority VLUNs will be overridden (-ovrd). Use only if hostname member exists.
type override_lower_priority: Boolean
==== Returns
VLUN id
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ MISSING_REQUIRED - Missing volume or hostname or lunid.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VOL MISSING_REQUIRED - Specified volume does not exist.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_HOST - Specified hostname not found.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_PORT - Specified port does not exist.
|
[
"Creates",
"a",
"new",
"VLUN",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L442-L449
|
20,758
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_vluns
|
def get_vluns
begin
@vlun.get_vluns
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_vluns
begin
@vlun.get_vluns
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_vluns",
"begin",
"@vlun",
".",
"get_vluns",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets VLUNs.
==== Returns
Array of VLUN objects
|
[
"Gets",
"VLUNs",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L456-L463
|
20,759
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_vlun
|
def get_vlun(volume_name)
begin
@vlun.get_vlun(volume_name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_vlun(volume_name)
begin
@vlun.get_vlun(volume_name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_vlun",
"(",
"volume_name",
")",
"begin",
"@vlun",
".",
"get_vlun",
"(",
"volume_name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets information about a VLUN.
==== Attributes
* volume_name: The volume name of the VLUN to find
type volume_name: String
==== Returns
VLUN object
==== Raises
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VLUN - VLUN doesn't exist
|
[
"Gets",
"information",
"about",
"a",
"VLUN",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L480-L487
|
20,760
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.delete_vlun
|
def delete_vlun(volume_name, lun_id, host_name = nil, port = nil)
begin
@vlun.delete_vlun(volume_name, lun_id, host_name, port)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def delete_vlun(volume_name, lun_id, host_name = nil, port = nil)
begin
@vlun.delete_vlun(volume_name, lun_id, host_name, port)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"delete_vlun",
"(",
"volume_name",
",",
"lun_id",
",",
"host_name",
"=",
"nil",
",",
"port",
"=",
"nil",
")",
"begin",
"@vlun",
".",
"delete_vlun",
"(",
"volume_name",
",",
"lun_id",
",",
"host_name",
",",
"port",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Deletes a VLUN.
==== Attributes
* volume_name: Volume name of the VLUN
type volume_name: String
* lun_id: LUN ID
type lun_id: Integer
* host_name: Name of the host which the volume is exported. For VLUN of port type,the value is empty
type host_name: String
* port: Specifies the system port of the VLUN export. It includes the system node number, PCI bus slot number, and card port number on the FC card in the format<node>:<slot>:<cardPort>
type port: Hash
port = {'node'=> 1, # System node (0-7)
'slot'=> 2, # PCI bus slot in the node (0-5)
'port'=>1} # Port number on the FC card (0-4)
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_MISSING_REQUIRED - Incomplete VLUN info. Missing
volumeName or lun, or both hostname and port.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_PORT_SELECTION - Specified port is invalid.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_EXCEEDS_RANGE - The LUN specified exceeds expected
range.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_HOST - The host does not exist
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VLUN - The VLUN does not exist
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_PORT - The port does not exist
* Hpe3parSdk::HTTPForbidden
- PERM_DENIED - Permission denied
|
[
"Deletes",
"a",
"VLUN",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L523-L530
|
20,761
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.query_qos_rules
|
def query_qos_rules
begin
@qos.query_qos_rules
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def query_qos_rules
begin
@qos.query_qos_rules
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"query_qos_rules",
"begin",
"@qos",
".",
"query_qos_rules",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets QoS Rules.
==== Returns
Array of QoSRule objects
|
[
"Gets",
"QoS",
"Rules",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L538-L545
|
20,762
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.query_qos_rule
|
def query_qos_rule(target_name, target_type = 'vvset')
begin
@qos.query_qos_rule(target_name, target_type)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def query_qos_rule(target_name, target_type = 'vvset')
begin
@qos.query_qos_rule(target_name, target_type)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"query_qos_rule",
"(",
"target_name",
",",
"target_type",
"=",
"'vvset'",
")",
"begin",
"@qos",
".",
"query_qos_rule",
"(",
"target_name",
",",
"target_type",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Queries a QoS rule
==== Attributes
* target_name : Name of the target. When targetType is sys, target name must be sys:all_others.
type target_name: String
* target_type : Target type is vvset or sys
type target_type: String
==== Returns
QoSRule object
==== Raises
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_QOS_RULE - QoS rule does not exist.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ILLEGAL_CHAR - Illegal character in the input.
|
[
"Queries",
"a",
"QoS",
"rule"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L565-L572
|
20,763
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.modify_qos_rules
|
def modify_qos_rules(target_name, qos_rules, target_type = QoStargetTypeConstants::VVSET)
if @current_version < @min_version && !qos_rules.nil?
qos_rules.delete_if { |key, _value| key == :latencyGoaluSecs }
end
begin
@qos.modify_qos_rules(target_name, qos_rules, target_type)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def modify_qos_rules(target_name, qos_rules, target_type = QoStargetTypeConstants::VVSET)
if @current_version < @min_version && !qos_rules.nil?
qos_rules.delete_if { |key, _value| key == :latencyGoaluSecs }
end
begin
@qos.modify_qos_rules(target_name, qos_rules, target_type)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"modify_qos_rules",
"(",
"target_name",
",",
"qos_rules",
",",
"target_type",
"=",
"QoStargetTypeConstants",
"::",
"VVSET",
")",
"if",
"@current_version",
"<",
"@min_version",
"&&",
"!",
"qos_rules",
".",
"nil?",
"qos_rules",
".",
"delete_if",
"{",
"|",
"key",
",",
"_value",
"|",
"key",
"==",
":latencyGoaluSecs",
"}",
"end",
"begin",
"@qos",
".",
"modify_qos_rules",
"(",
"target_name",
",",
"qos_rules",
",",
"target_type",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Modifies an existing QOS rules
The QoS rule can be applied to VV sets. By using sys:all_others,
you can apply the rule to all volumes in the system for which no
QoS rule has been defined.
ioMinGoal and ioMaxLimit must be used together to set I/O limits.
Similarly, bwMinGoalKB and bwMaxLimitKB must be used together.
If ioMaxLimitOP is set to 2 (no limit), ioMinGoalOP must also be
to set to 2 (zero), and vice versa. They cannot be set to
'none' individually. Similarly, if bwMaxLimitOP is set to 2 (no
limit), then bwMinGoalOP must also be set to 2.
If ioMaxLimitOP is set to 1 (no limit), ioMinGoalOP must also be
to set to 1 (zero) and vice versa. Similarly, if bwMaxLimitOP is
set to 1 (zero), then bwMinGoalOP must also be set to 1.
The ioMinGoalOP and ioMaxLimitOP fields take precedence over
the ioMinGoal and ioMaxLimit fields.
The bwMinGoalOP and bwMaxLimitOP fields take precedence over
the bwMinGoalKB and bwMaxLimitKB fields
==== Attributes
* target_name: Name of the target object on which the QoS rule will be created.
type target_name: String
* target_type: Type of QoS target, either vvset or sys.Refer Hpe3parSdk::QoStargetTypeConstants for complete enumeration
type target_type: String
* qos_rules: QoS options
type qos_rules: Hash
qos_rules = {
'priority'=> 2, # Refer Hpe3parSdk::QoSpriorityEnumeration for complete enumeration
'bwMinGoalKB'=> 1024, # bandwidth rate minimum goal in
# kilobytes per second
'bwMaxLimitKB'=> 1024, # bandwidth rate maximum limit in
# kilobytes per second
'ioMinGoal'=> 10000, # I/O-per-second minimum goal.
'ioMaxLimit'=> 2000000, # I/0-per-second maximum limit
'enable'=> True, # QoS rule for target enabled?
'bwMinGoalOP'=> 1, # zero none operation enum, when set to
# 1, bandwidth minimum goal is 0
# when set to 2, the bandwidth minimum
# goal is none (NoLimit)
'bwMaxLimitOP'=> 1, # zero none operation enum, when set to
# 1, bandwidth maximum limit is 0
# when set to 2, the bandwidth maximum
# limit is none (NoLimit)
'ioMinGoalOP'=> 1, # zero none operation enum, when set to
# 1, I/O minimum goal minimum goal is 0
# when set to 2, the I/O minimum goal is
# none (NoLimit)
'ioMaxLimitOP'=> 1, # zero none operation enum, when set to
# 1, I/O maximum limit is 0
# when set to 2, the I/O maximum limit
# is none (NoLimit)
'latencyGoal'=> 5000, # Latency goal in milliseconds
'defaultLatency'=> false# Use latencyGoal or defaultLatency?
}
==== Raises
* Hpe3parSdk::HTTPBadRequest
INV_INPUT_EXCEEDS_RANGE - Invalid input: number exceeds expected
range.
* Hpe3parSdk::HTTPNotFound
NON_EXISTENT_QOS_RULE - QoS rule does not exists.
* Hpe3parSdk::HTTPBadRequest
INV_INPUT_ILLEGAL_CHAR - Illegal character in the input.
* Hpe3parSdk::HTTPBadRequest
EXISTENT_QOS_RULE - QoS rule already exists.
* Hpe3parSdk::HTTPBadRequest
INV_INPUT_IO_MIN_GOAL_GRT_MAX_LIMIT - I/O-per-second maximum limit
should be greater than the minimum goal.
* Hpe3parSdk::HTTPBadRequest
INV_INPUT_BW_MIN_GOAL_GRT_MAX_LIMIT - Bandwidth maximum limit
should be greater than the minimum goal.
* Hpe3parSdk::HTTPBadRequest
INV_INPUT_BELOW_RANGE - I/O-per-second limit is below
range. Bandwidth limit is below range.
* Hpe3parSdk::HTTPBadRequest
UNLICENSED_FEATURE - The system is not licensed for QoS.
|
[
"Modifies",
"an",
"existing",
"QOS",
"rules"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L747-L757
|
20,764
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.delete_qos_rules
|
def delete_qos_rules(target_name, target_type = QoStargetTypeConstants::VVSET)
begin
@qos.delete_qos_rules(target_name, target_type)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def delete_qos_rules(target_name, target_type = QoStargetTypeConstants::VVSET)
begin
@qos.delete_qos_rules(target_name, target_type)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"delete_qos_rules",
"(",
"target_name",
",",
"target_type",
"=",
"QoStargetTypeConstants",
"::",
"VVSET",
")",
"begin",
"@qos",
".",
"delete_qos_rules",
"(",
"target_name",
",",
"target_type",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Deletes QoS rules.
==== Attributes
* target_name: Name of the target. When target_type is sys, target_name must be sys:all_others.
type target_name: String
* target_type: target type is vvset or sys
type target_type: String
==== Raises
* Hpe3parSdk::HTTPNotFound
NON_EXISTENT_QOS_RULE - QoS rule does not exist.
* Hpe3parSdk::HTTPBadRequest
INV_INPUT_ILLEGAL_CHAR - Illegal character in the input
|
[
"Deletes",
"QoS",
"rules",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L774-L781
|
20,765
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_hosts
|
def get_hosts
begin
@host.get_hosts
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_hosts
begin
@host.get_hosts
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_hosts",
"begin",
"@host",
".",
"get_hosts",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets all hosts.
==== Returns
Array of Host.
|
[
"Gets",
"all",
"hosts",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L788-L795
|
20,766
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_host
|
def get_host(name)
begin
@host.get_host(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_host(name)
begin
@host.get_host(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_host",
"(",
"name",
")",
"begin",
"@host",
".",
"get_host",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets host information by name.
==== Attributes
* name - The name of the host to find.
type name: String
==== Returns
Host.
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT - Invalid URI syntax.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_HOST - Host not found.
* Hpe3parSdk::HTTPInternalServerError
- INT_SERV_ERR - Internal server error.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ILLEGAL_CHAR - Host name contains invalid character.
|
[
"Gets",
"host",
"information",
"by",
"name",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L818-L825
|
20,767
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.create_host
|
def create_host(name, iscsi_names = nil, fcwwns = nil, optional = nil)
begin
@host.create_host(name, iscsi_names, fcwwns, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def create_host(name, iscsi_names = nil, fcwwns = nil, optional = nil)
begin
@host.create_host(name, iscsi_names, fcwwns, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"create_host",
"(",
"name",
",",
"iscsi_names",
"=",
"nil",
",",
"fcwwns",
"=",
"nil",
",",
"optional",
"=",
"nil",
")",
"begin",
"@host",
".",
"create_host",
"(",
"name",
",",
"iscsi_names",
",",
"fcwwns",
",",
"optional",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Creates a new Host.
==== Attributes
* name - The name of the host.
type name: String
* iscsi_names - Array of iSCSI iqns.
type iscsi_names: Array
* fcwwns - Array of Fibre Channel World Wide Names.
type fcwwns: Array
* optional - The optional stuff.
type optional: Hash
optional = {
'persona'=> 1, # Refer Hpe3parSdk::HostPersona for complete enumeration.
# 3.1.3 default: Generic-ALUA
# 3.1.2 default: General
'domain'=> 'myDomain', # Create the host in the
# specified domain, or default
# domain if unspecified.
'forceTearDown'=> false, # If True, force to tear down
# low-priority VLUN exports.
'descriptors'=>
{'location'=> 'earth', # The host's location
'IPAddr'=> '10.10.10.10', # The host's IP address
'os'=> 'linux', # The operating system running on the host.
'model'=> 'ex', # The host's model
'contact'=> 'Smith', # The host's owner and contact
'comment'=> "Joe's box"} # Additional host information
}
==== Raises
* Hpe3parSdk::HTTPForbidden
- PERM_DENIED - Permission denied.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_MISSING_REQUIRED - Name not specified.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_PARAM_CONFLICT - FCWWNs and iSCSINames are both specified.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_EXCEEDS_LENGTH - Host name, domain name, or iSCSI name is too long.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_EMPTY_STR - Input string (for domain name, iSCSI name, etc.) is empty.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ILLEGAL_CHAR - Any error from host-name or domain-name parsing.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_TOO_MANY_WWN_OR_iSCSI - More than 1024 WWNs or iSCSI names are specified.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_WRONG_TYPE - The length of WWN is not 16. WWN specification contains non-hexadecimal digit.
* Hpe3parSdk::HTTPConflict
- EXISTENT_PATH - host WWN/iSCSI name already used by another host.
* Hpe3parSdk::HTTPConflict
- EXISTENT_HOST - host name is already used.
* Hpe3parSdk::HTTPBadRequest
- NO_SPACE - No space to create host.
|
[
"Creates",
"a",
"new",
"Host",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L881-L888
|
20,768
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.modify_host
|
def modify_host(name, mod_request)
begin
@host.modify_host(name, mod_request)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def modify_host(name, mod_request)
begin
@host.modify_host(name, mod_request)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"modify_host",
"(",
"name",
",",
"mod_request",
")",
"begin",
"@host",
".",
"modify_host",
"(",
"name",
",",
"mod_request",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Modifies an existing Host.
==== Attributes
* name - Name of the host.
type name: String
* mod_request - Objects for host modification request.
type mod_request: Hash
mod_request = {
'newName'=> 'myNewName', # New name of the host
'pathOperation'=> 1, # Refer Hpe3parSdk::HostEditOperation for complete enumeration
'FCWWNs'=> [], # One or more WWN to set for the host.
'iSCSINames'=> [], # One or more iSCSI names to set for the host.
'forcePathRemoval'=> false, # If True, remove SSN(s) or
# iSCSI(s) even if there are
# VLUNs exported to host
'persona'=> 1, # Refer Hpe3parSdk::HostPersona for complete enumeration.
'descriptors'=>
{'location'=> 'earth', # The host's location
'IPAddr'=> '10.10.10.10', # The host's IP address
'os'=> 'linux', # The operating system running on the host.
'model'=> 'ex', # The host's model
'contact'=> 'Smith', # The host's owner and contact
'comment'=> 'Joes box'} # Additional host information
'chapOperation'=> 1, # Refer Hpe3parSdk::HostEditOperation for complete enumeration
'chapOperationMode'=> TARGET, # Refer Hpe3parSdk::ChapOperationMode for complete enumeration
'chapName'=> 'MyChapName', # The chap name
'chapSecret'=> 'xyz', # The chap secret for the host or the target
'chapSecretHex'=> false, # If True, the chapSecret is treated as Hex.
'chapRemoveTargetOnly'=> true # If True, then remove target chap only
}
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT - Missing host name.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_PARAM_CONFLICT - Both iSCSINames & FCWWNs are specified. (lot of other possibilities).
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ONE_REQUIRED - iSCSINames or FCWwns missing.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ONE_REQUIRED - No path operation specified.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_BAD_ENUM_VALUE - Invalid enum value.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_MISSING_REQUIRED - Required fields missing.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_EXCEEDS_LENGTH - Host descriptor argument length, new host name, or iSCSI name is too long.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ILLEGAL_CHAR - Error parsing host or iSCSI name.
* Hpe3parSdk::HTTPConflict
- EXISTENT_HOST - New host name is already used.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_HOST - Host to be modified does not exist.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_TOO_MANY_WWN_OR_iSCSI - More than 1024 WWNs or iSCSI names are specified.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_WRONG_TYPE - Input value is of the wrong type.
* Hpe3parSdk::HTTPConflict
- EXISTENT_PATH - WWN or iSCSI name is already claimed by other host.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_BAD_LENGTH - CHAP hex secret length is not 16 bytes, or chap ASCII secret length is not 12 to 16 characters.
* Hpe3parSdk::HTTPNotFound
- NO_INITIATOR_CHAP - Setting target CHAP without initiator CHAP.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_CHAP - Remove non-existing CHAP.
* Hpe3parSdk::HTTPConflict
- NON_UNIQUE_CHAP_SECRET - CHAP secret is not unique.
* Hpe3parSdk::HTTPConflict
- EXPORTED_VLUN - Setting persona with active export; remove a host path on an active export.
* Hpe3parSdk::HTTPBadRequest
- NON_EXISTENT_PATH - Remove a non-existing path.
* Hpe3parSdk::HTTPConflict
- LUN_HOSTPERSONA_CONFLICT - LUN number and persona capability conflict.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_DUP_PATH - Duplicate path specified.
|
[
"Modifies",
"an",
"existing",
"Host",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L966-L973
|
20,769
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.delete_host
|
def delete_host(name)
begin
@host.delete_host(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def delete_host(name)
begin
@host.delete_host(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"delete_host",
"(",
"name",
")",
"begin",
"@host",
".",
"delete_host",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Deletes a host.
==== Attributes
* name - The name of host to be deleted.
type name: String
==== Raises
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_HOST - Host not found
* Hpe3parSdk::HTTPConflict
- HOST_IN_SET - Host is a member of a set
|
[
"Deletes",
"a",
"host",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L988-L995
|
20,770
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.query_host_by_fc_path
|
def query_host_by_fc_path(wwn = nil)
begin
@host.query_host_by_fc_path(wwn)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def query_host_by_fc_path(wwn = nil)
begin
@host.query_host_by_fc_path(wwn)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"query_host_by_fc_path",
"(",
"wwn",
"=",
"nil",
")",
"begin",
"@host",
".",
"query_host_by_fc_path",
"(",
"wwn",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Finds the host with the specified FC WWN path.
==== Attributes
* wwn - Lookup based on WWN.
type wwn: String
==== Returns
Host with specified FC WWN.
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT - Invalid URI syntax.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_HOST - HOST Not Found
* Hpe3parSdk::HTTPInternalServerError
- INTERNAL_SERVER_ERR - Internal server error.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ILLEGAL_CHAR - Host name contains invalid character.
|
[
"Finds",
"the",
"host",
"with",
"the",
"specified",
"FC",
"WWN",
"path",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1018-L1025
|
20,771
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.query_host_by_iscsi_path
|
def query_host_by_iscsi_path(iqn = nil)
begin
@host.query_host_by_iscsi_path(iqn)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def query_host_by_iscsi_path(iqn = nil)
begin
@host.query_host_by_iscsi_path(iqn)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"query_host_by_iscsi_path",
"(",
"iqn",
"=",
"nil",
")",
"begin",
"@host",
".",
"query_host_by_iscsi_path",
"(",
"iqn",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Finds the host with the specified iSCSI initiator.
==== Attributes
* iqn - Lookup based on iSCSI initiator.
type iqn: String
==== Returns
Host with specified IQN.
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT - Invalid URI syntax.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_HOST - The specified host not found.
* Hpe3parSdk::HTTPInternalServerError
- INTERNAL_SERVER_ERR - Internal server error.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ILLEGAL_CHAR - The host name contains invalid character.
|
[
"Finds",
"the",
"host",
"with",
"the",
"specified",
"iSCSI",
"initiator",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1048-L1055
|
20,772
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_host_sets
|
def get_host_sets
begin
@host_set.get_host_sets
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_host_sets
begin
@host_set.get_host_sets
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_host_sets",
"begin",
"@host_set",
".",
"get_host_sets",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets all host sets.
==== Returns
Array of HostSet.
|
[
"Gets",
"all",
"host",
"sets",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1062-L1069
|
20,773
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.delete_host_set
|
def delete_host_set(name)
begin
@host_set.delete_host_set(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def delete_host_set(name)
begin
@host_set.delete_host_set(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"delete_host_set",
"(",
"name",
")",
"begin",
"@host_set",
".",
"delete_host_set",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Deletes a HostSet.
==== Attributes
* name - The hostset to delete.
type name: String
==== Raises
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_SET - The set does not exists.
* Hpe3parSdk::HTTPConflict
- EXPORTED_VLUN - The host set has exported VLUNs.
|
[
"Deletes",
"a",
"HostSet",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1122-L1129
|
20,774
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.modify_host_set
|
def modify_host_set(name, action = nil, setmembers = nil, new_name = nil, comment = nil)
begin
@host_set.modify_host_set(name, action, setmembers, new_name, comment)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def modify_host_set(name, action = nil, setmembers = nil, new_name = nil, comment = nil)
begin
@host_set.modify_host_set(name, action, setmembers, new_name, comment)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"modify_host_set",
"(",
"name",
",",
"action",
"=",
"nil",
",",
"setmembers",
"=",
"nil",
",",
"new_name",
"=",
"nil",
",",
"comment",
"=",
"nil",
")",
"begin",
"@host_set",
".",
"modify_host_set",
"(",
"name",
",",
"action",
",",
"setmembers",
",",
"new_name",
",",
"comment",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Modifies a HostSet.
==== Attributes
* name - Hostset name
type name: String
* action - Add or Remove host(s) from the set
type action: Refer values of Hpe3parSdk::SetCustomAction::MEM_ADD and Hpe3parSdk::SetCustomAction::MEM_REMOVE
* setmembers - Host(s) to add to the set, the existence of the host(s) will not be checked
type setmembers: Array of String
* new_name - New name of set
type new_name: String
* comment - New comment for the set
type comment: String
==== Raises
* Hpe3parSdk::HTTPBadRequest
- EXISTENT_SET - The set already exits.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_SET - The set does not exists.
* Hpe3parSdk::HTTPConflict
- MEMBER_IN_DOMAINSET - The host is in a domain set.
* Hpe3parSdk::HTTPConflict
- MEMBER_IN_SET - The object is already part of the set.
* Hpe3parSdk::HTTPNotFound
- MEMBER_NOT_IN_SET - The object is not part of the set.
* Hpe3parSdk::HTTPConflict
- MEMBER_NOT_IN_SAME_DOMAIN - Objects must be in the same domain to perform this operation.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_DUP_NAME - Invalid input (duplicate name).
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_PARAM_CONFLICT - Invalid input (parameters cannot be present at the same time).
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ILLEGAL_CHAR - Invalid contains one or more illegal characters.
|
[
"Modifies",
"a",
"HostSet",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1166-L1173
|
20,775
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.find_host_sets
|
def find_host_sets(host_name)
begin
@host_set.find_host_sets(host_name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def find_host_sets(host_name)
begin
@host_set.find_host_sets(host_name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"find_host_sets",
"(",
"host_name",
")",
"begin",
"@host_set",
".",
"find_host_sets",
"(",
"host_name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Returns an array of every Hostset the given host is a part of. The array can contain zero, one, or multiple items.
==== Attributes
* host_name - The host name of whose hostset is to be found.
type host_name: String
==== Returns
Array of HostSet.
|
[
"Returns",
"an",
"array",
"of",
"every",
"Hostset",
"the",
"given",
"host",
"is",
"a",
"part",
"of",
".",
"The",
"array",
"can",
"contain",
"zero",
"one",
"or",
"multiple",
"items",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1219-L1226
|
20,776
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_host_set
|
def get_host_set(name)
begin
@host_set.get_host_set(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_host_set(name)
begin
@host_set.get_host_set(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_host_set",
"(",
"name",
")",
"begin",
"@host_set",
".",
"get_host_set",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets hostset information by name.
==== Attributes
* name - The name of the hostset to find.
type name: String
==== Returns
HostSet.
==== Raises
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_SET - The set does not exist.
|
[
"Gets",
"hostset",
"information",
"by",
"name",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1243-L1250
|
20,777
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_host_vluns
|
def get_host_vluns(host_name)
begin
@host.get_host_vluns(host_name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_host_vluns(host_name)
begin
@host.get_host_vluns(host_name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_host_vluns",
"(",
"host_name",
")",
"begin",
"@host",
".",
"get_host_vluns",
"(",
"host_name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets all of the VLUNs on a specific host.
==== Attributes
* host_name - Name of the host.
type host_name: String
==== Returns
Array of VLUN.
==== Raises
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_HOST - The specified host not found.
|
[
"Gets",
"all",
"of",
"the",
"VLUNs",
"on",
"a",
"specific",
"host",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1267-L1274
|
20,778
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_volumes
|
def get_volumes
begin
@volume.get_volumes(VolumeCopyType::BASE_VOLUME)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_volumes
begin
@volume.get_volumes(VolumeCopyType::BASE_VOLUME)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_volumes",
"begin",
"@volume",
".",
"get_volumes",
"(",
"VolumeCopyType",
"::",
"BASE_VOLUME",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets all Volumes in the array
==== Returns
Array of VirtualVolume
|
[
"Gets",
"all",
"Volumes",
"in",
"the",
"array"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1281-L1288
|
20,779
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_snapshots
|
def get_snapshots
begin
@volume.get_volumes(VolumeCopyType::VIRTUAL_COPY)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_snapshots
begin
@volume.get_volumes(VolumeCopyType::VIRTUAL_COPY)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_snapshots",
"begin",
"@volume",
".",
"get_volumes",
"(",
"VolumeCopyType",
"::",
"VIRTUAL_COPY",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets the list of snapshots in the array
==== Returns
Array of VirtualVolume
|
[
"Gets",
"the",
"list",
"of",
"snapshots",
"in",
"the",
"array"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1295-L1302
|
20,780
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_volume
|
def get_volume(name)
begin
@volume.get_volume(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_volume(name)
begin
@volume.get_volume(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_volume",
"(",
"name",
")",
"begin",
"@volume",
".",
"get_volume",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets information about a volume by name
==== Attributes
* name - The name of the volume to find
type name: String
==== Returns
VirtualVolume
==== Raises
* Hpe3parSdk::HPE3PARException
Error with code: 23 message: volume does not exist
|
[
"Gets",
"information",
"about",
"a",
"volume",
"by",
"name"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1319-L1326
|
20,781
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_volume_by_wwn
|
def get_volume_by_wwn(wwn)
begin
@volume.get_volume_by_wwn(wwn)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_volume_by_wwn(wwn)
begin
@volume.get_volume_by_wwn(wwn)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_volume_by_wwn",
"(",
"wwn",
")",
"begin",
"@volume",
".",
"get_volume_by_wwn",
"(",
"wwn",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets information about a volume by wwn
==== Attributes
* wwn - The wwn of the volume to find
type wwn: String
==== Returns
* VirtualVolume
==== Raises
* Hpe3parSdk::HPE3PARException
Error with code: 23 message: volume does not exist
|
[
"Gets",
"information",
"about",
"a",
"volume",
"by",
"wwn"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1343-L1350
|
20,782
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.create_volume
|
def create_volume(name, cpg_name, size_MiB, optional = nil)
if @current_version < @min_version_with_compression && !optional.nil?
optional.delete_if { |key, _value| key == :compression }
end
begin
@volume.create_volume(name, cpg_name, size_MiB, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def create_volume(name, cpg_name, size_MiB, optional = nil)
if @current_version < @min_version_with_compression && !optional.nil?
optional.delete_if { |key, _value| key == :compression }
end
begin
@volume.create_volume(name, cpg_name, size_MiB, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"create_volume",
"(",
"name",
",",
"cpg_name",
",",
"size_MiB",
",",
"optional",
"=",
"nil",
")",
"if",
"@current_version",
"<",
"@min_version_with_compression",
"&&",
"!",
"optional",
".",
"nil?",
"optional",
".",
"delete_if",
"{",
"|",
"key",
",",
"_value",
"|",
"key",
"==",
":compression",
"}",
"end",
"begin",
"@volume",
".",
"create_volume",
"(",
"name",
",",
"cpg_name",
",",
"size_MiB",
",",
"optional",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Creates a new volume.
==== Attributes
* name - the name of the volume
type name: String
* cpg_name - the name of the destination CPG
type cpg_name: String
* size_MiB - size in MiB for the volume
type size_MiB: Integer
* optional - hash of other optional items
type optional: hash
optional = {
'id' => 12, # Volume ID. If not specified, next
# available is chosen
'comment' => 'some comment', # Additional information up to 511
# characters
'policies: { # Specifies VV policies
'staleSS' => false, # True allows stale snapshots.
'oneHost' => true, # True constrains volume export to
# single host or host cluster
'zeroDetect' => true, # True requests Storage System to
# scan for zeros in incoming write
# data
'system' => false, # True special volume used by system
# False is normal user volume
'caching' => true}, # Read-only. True indicates write &
# read caching & read ahead enabled
'snapCPG' => 'CPG name', # CPG Used for snapshots
'ssSpcAllocWarningPct' => 12, # Snapshot space allocation warning
'ssSpcAllocLimitPct' => 22, # Snapshot space allocation limit
'tpvv' => true, # True: Create TPVV
# False (default) Create FPVV
'usrSpcAllocWarningPct' => 22, # Enable user space allocation
# warning
'usrSpcAllocLimitPct' => 22, # User space allocation limit
'expirationHours' => 256, # Relative time from now to expire
# volume (max 43,800 hours)
'retentionHours' => 256 # Relative time from now to retain
}
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT - Invalid Parameter
* Hpe3parSdk::HTTPBadRequest
- TOO_LARGE - Volume size above limit
* Hpe3parSdk::HTTPBadRequest
- NO_SPACE - Not Enough space is available
* Hpe3parSdk::HTTPForbidden
- PERM_DENIED - Permission denied
* Hpe3parSdk::HTTPConflict
- EXISTENT_SV - Volume Exists already
|
[
"Creates",
"a",
"new",
"volume",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1406-L1416
|
20,783
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.modify_volume
|
def modify_volume(name, volume_mods)
begin
@volume.modify_volume(name, volume_mods)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def modify_volume(name, volume_mods)
begin
@volume.modify_volume(name, volume_mods)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"modify_volume",
"(",
"name",
",",
"volume_mods",
")",
"begin",
"@volume",
".",
"modify_volume",
"(",
"name",
",",
"volume_mods",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Modifies a volume
==== Attributes
* name - the name of the volume
type name: String
* volumeMods - Hash of volume attributes to change
type volumeMods: Hash
volumeMods = {
'newName' => 'newName', # New volume name
'comment' => 'some comment', # New volume comment
'snapCPG' => 'CPG name', # Snapshot CPG name
'policies: { # Specifies VV policies
'staleSS' => false, # True allows stale snapshots.
'oneHost' => true, # True constrains volume export to
# single host or host cluster
'zeroDetect' => true, # True requests Storage System to
# scan for zeros in incoming write
# data
'system' => false, # True special volume used by system
# False is normal user volume
'caching' => true}, # Read-only. True indicates write &
# read caching & read ahead enabled
'ssSpcAllocWarningPct' => 12, # Snapshot space allocation warning
'ssSpcAllocLimitPct' => 22, # Snapshot space allocation limit
'tpvv' => true, # True: Create TPVV
# False: (default) Create FPVV
'usrSpcAllocWarningPct' => 22, # Enable user space allocation
# warning
'usrSpcAllocLimitPct' => 22, # User space allocation limit
'userCPG' => 'User CPG name', # User CPG name
'expirationHours' => 256, # Relative time from now to expire
# volume (max 43,800 hours)
'retentionHours' => 256, # Relative time from now to retain
# volume (max 43,800 hours)
'rmSsSpcAllocWarning' => false, # True removes snapshot space
# allocation warning.
# False sets it when value > 0
'rmUsrSpcAllocWarwaning' => false,# True removes user space
# allocation warning.
# False sets it when value > 0
'rmExpTime' => false, # True resets expiration time to 0.
# False sets it when value > 0
'rmSsSpcAllocLimit' => false, # True removes snapshot space
# allocation limit.
# False sets it when value > 0
'rmUsrSpcAllocLimit' => false # True removes user space
# allocation limit.
# False sets it when value > 0
}
==== Raises:
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_WARN_GT_LIMIT - Allocation warning level is higher than
the limit.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_USR_ALRT_NON_TPVV - User space allocation alerts are
valid only with a TPVV.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_RETAIN_GT_EXPIRE - Retention time is greater than
expiration time.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_VV_POLICY - Invalid policy specification (for example,
caching or system is set to true).
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_EXCEEDS_LENGTH - Invalid input: string length exceeds
limit.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_TIME - Invalid time specified.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_MODIFY_USR_CPG_TPVV - usr_cpg cannot be modified
on a TPVV.
* Hpe3parSdk::HTTPBadRequest
- UNLICENSED_FEATURE - Retention time cannot be modified on a
system without the Virtual Lock license.
* Hpe3parSdk::HTTPForbidden
- CPG_NOT_IN_SAME_DOMAIN - Snap CPG is not in the same domain as
the user CPG.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_PEER_VOLUME - Cannot modify a peer volume.
* Hpe3parSdk::HTTPInternalServerError
- INT_SERV_ERR - Metadata of the VV is corrupted.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_SYS_VOLUME - Cannot modify retention time on a
system volume.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_INTERNAL_VOLUME - Cannot modify an internal
volume
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_VOLUME_NOT_DEFINED_ALL_NODES - Cannot modify a
volume until the volume is defined on all volumes.
* Hpe3parSdk::HTTPConflict
- INVALID_OPERATION_VV_ONLINE_COPY_IN_PROGRESS - Cannot modify a
volume when an online copy for that volume is in progress.
* Hpe3parSdk::HTTPConflict
- INVALID_OPERATION_VV_VOLUME_CONV_IN_PROGRESS - Cannot modify a
volume in the middle of a conversion operation.
* Hpe3parSdk::HTTPConflict
- INVALID_OPERATION_VV_SNAPSPACE_NOT_MOVED_TO_CPG - Snapshot space
of a volume needs to be moved to a CPG before the user space.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_VOLUME_ACCOUNTING_IN_PROGRESS - The volume
cannot be renamed until snapshot accounting has finished.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_ZERO_DETECT_TPVV - The zero_detect policy can be
used only on TPVVs.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_CPG_ON_SNAPSHOT - CPG cannot be assigned to a
snapshot.
|
[
"Modifies",
"a",
"volume"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1558-L1565
|
20,784
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.grow_volume
|
def grow_volume(name, amount)
begin
@volume.grow_volume(name, amount)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def grow_volume(name, amount)
begin
@volume.grow_volume(name, amount)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"grow_volume",
"(",
"name",
",",
"amount",
")",
"begin",
"@volume",
".",
"grow_volume",
"(",
"name",
",",
"amount",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Grows an existing volume by 'amount' Mebibytes.
==== Attributes
* name - the name of the volume
type name: String
* amount: the additional size in MiB to add, rounded up to the next chunklet size (e.g. 256 or 1000 MiB)
type amount: Integer
==== Raises:
* Hpe3parSdk::HTTPForbidden
- VV_NOT_IN_SAME_DOMAIN - The volume is not in the same domain.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VOL - The volume does not exist.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_UNSUPPORTED_VV_TYPE - Invalid operation: Cannot
grow this type of volume.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_TUNE_IN_PROGRESS - Invalid operation: Volume
tuning is in progress.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_EXCEEDS_LENGTH - Invalid input: String length exceeds
limit.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_VV_GROW_SIZE - Invalid grow size.
* Hpe3parSdk::HTTPForbidden
- VV_NEW_SIZE_EXCEEDS_CPG_LIMIT - New volume size exceeds CPG limit
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_INTERNAL_VOLUME - This operation is not allowed
on an internal volume.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_VOLUME_CONV_IN_PROGRESS - Invalid operation: VV
conversion is in progress.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_VOLUME_COPY_IN_PROGRESS - Invalid operation:
online copy is in progress.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_CLEANUP_IN_PROGRESS - Internal volume cleanup is
in progress.
* Hpe3parSdk::HTTPForbidden
- VV_IS_BEING_REMOVED - The volume is being removed.
* Hpe3parSdk::HTTPForbidden
- VV_IN_INCONSISTENT_STATE - The volume has an internal consistency
error.
* Hpe3parSdk::HTTPForbidden
- VV_SIZE_CANNOT_REDUCE - New volume size is smaller than the
current size.
* Hpe3parSdk::HTTPForbidden
- VV_NEW_SIZE_EXCEEDS_LIMITS - New volume size exceeds the limit.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_SA_SD_SPACE_REMOVED - Invalid operation: Volume
SA/SD space is being removed.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_IS_BUSY - Invalid operation: Volume is currently
busy.
* Hpe3parSdk::HTTPForbidden
- VV_NOT_STARTED - Volume is not started.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_IS_PCOPY - Invalid operation: Volume is a
physical copy.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_NOT_IN_NORMAL_STATE - Volume state is not normal
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_PROMOTE_IN_PROGRESS - Invalid operation: Volume
promotion is in progress.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_PARENT_OF_PCOPY - Invalid operation: Volume is
the parent of physical copy.
* Hpe3parSdk::HTTPBadRequest
- NO_SPACE - Insufficent space for requested operation.
|
[
"Grows",
"an",
"existing",
"volume",
"by",
"amount",
"Mebibytes",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1638-L1645
|
20,785
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.create_physical_copy
|
def create_physical_copy(src_name, dest_name, dest_cpg, optional = nil)
if @current_version < @min_version_with_compression && !optional.nil?
[:compression, :allowRemoteCopyParent, :skipZero].each { |key| optional.delete key }
end
begin
@volume.create_physical_copy(src_name, dest_name, dest_cpg, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def create_physical_copy(src_name, dest_name, dest_cpg, optional = nil)
if @current_version < @min_version_with_compression && !optional.nil?
[:compression, :allowRemoteCopyParent, :skipZero].each { |key| optional.delete key }
end
begin
@volume.create_physical_copy(src_name, dest_name, dest_cpg, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"create_physical_copy",
"(",
"src_name",
",",
"dest_name",
",",
"dest_cpg",
",",
"optional",
"=",
"nil",
")",
"if",
"@current_version",
"<",
"@min_version_with_compression",
"&&",
"!",
"optional",
".",
"nil?",
"[",
":compression",
",",
":allowRemoteCopyParent",
",",
":skipZero",
"]",
".",
"each",
"{",
"|",
"key",
"|",
"optional",
".",
"delete",
"key",
"}",
"end",
"begin",
"@volume",
".",
"create_physical_copy",
"(",
"src_name",
",",
"dest_name",
",",
"dest_cpg",
",",
"optional",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Creates a physical copy of a VirtualVolume
==== Attributes
* src_name - the source volume name
type src_name: String
* dest_name - the destination volume name
type dest_name: String
* dest_cpg - the destination CPG
type dest_cpg: String
* optional - Hash of optional parameters
type optional: Hash
optional = {
'online' => false, # should physical copy be
# performed online?
'tpvv' => false, # use thin provisioned space
# for destination
# (online copy only)
'snapCPG' => 'OpenStack_SnapCPG', # snapshot CPG for the
# destination
# (online copy only)
'saveSnapshot' => false, # save the snapshot of the
# source volume
'priority' => 1 # taskPriorityEnum (does not
# apply to online copy - Hpe3parSdk::TaskPriority)
}
|
[
"Creates",
"a",
"physical",
"copy",
"of",
"a",
"VirtualVolume"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1674-L1684
|
20,786
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.delete_physical_copy
|
def delete_physical_copy(name)
begin
@volume.delete_volume(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def delete_physical_copy(name)
begin
@volume.delete_volume(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"delete_physical_copy",
"(",
"name",
")",
"begin",
"@volume",
".",
"delete_volume",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Deletes a physical copy
==== Attributes
* name - the name of the clone volume
type name: String
==== Raises:
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VOL - The volume does not exist
* Hpe3parSdk::HTTPForbidden
- PERM_DENIED - Permission denied
* Hpe3parSdk::HTTPForbidden
- RETAINED - Volume retention time has not expired
* Hpe3parSdk::HTTPForbidden
- HAS_RO_CHILD - Volume has read-only child
* Hpe3parSdk::HTTPConflict
- HAS_CHILD - The volume has a child volume
* Hpe3parSdk::HTTPConflict
- IN_USE - The volume is in use by VV set, VLUN, etc
|
[
"Deletes",
"a",
"physical",
"copy"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1706-L1713
|
20,787
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.tune_volume
|
def tune_volume(name, tune_operation, optional = nil)
if @current_version < @min_version_with_compression && !optional.nil?
optional.delete_if { |key, _value| key == :compression }
end
begin
object_hash = @volume.tune_volume(name, tune_operation, optional)
get_task(object_hash['taskid'])
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def tune_volume(name, tune_operation, optional = nil)
if @current_version < @min_version_with_compression && !optional.nil?
optional.delete_if { |key, _value| key == :compression }
end
begin
object_hash = @volume.tune_volume(name, tune_operation, optional)
get_task(object_hash['taskid'])
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"tune_volume",
"(",
"name",
",",
"tune_operation",
",",
"optional",
"=",
"nil",
")",
"if",
"@current_version",
"<",
"@min_version_with_compression",
"&&",
"!",
"optional",
".",
"nil?",
"optional",
".",
"delete_if",
"{",
"|",
"key",
",",
"_value",
"|",
"key",
"==",
":compression",
"}",
"end",
"begin",
"object_hash",
"=",
"@volume",
".",
"tune_volume",
"(",
"name",
",",
"tune_operation",
",",
"optional",
")",
"get_task",
"(",
"object_hash",
"[",
"'taskid'",
"]",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Tunes a volume
==== Attributes
* name - the volume name
type name: String
* tune_operation - Enum of tune operation - 1: Change User CPG, 2: Change snap CPG
type dest_name: Integer
* optional - hash of optional parameters
type optional: hash
optional = {
'userCPG' => 'user_cpg', # Specifies the new user
# CPG to which the volume
# will be tuned.
'snapCPG' => 'snap_cpg', # Specifies the snap CPG to
# which the volume will be
# tuned.
'conversionOperation' => 1, # conversion operation enum. Refer Hpe3parSdk::VolumeConversionOperation
'keepVV' => 'new_volume', # Name of the new volume
# where the original logical disks are saved.
'compression' => true # Enables (true) or disables (false) compression.
# You cannot compress a fully provisioned volume.
}
|
[
"Tunes",
"a",
"volume"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1739-L1750
|
20,788
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.find_all_volume_sets
|
def find_all_volume_sets(name)
begin
@volume_set.find_all_volume_sets(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def find_all_volume_sets(name)
begin
@volume_set.find_all_volume_sets(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"find_all_volume_sets",
"(",
"name",
")",
"begin",
"@volume_set",
".",
"find_all_volume_sets",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Returns an array of every VolumeSet the given volume is a part of.
The array can contain zero, one, or multiple items.
==== Attributes
* name - the volume name
type name: String
==== Returns
Array of VolumeSet
==== Raises
* Hpe3parSdk::HTTPForbidden
- VV_IN_INCONSISTENT_STATE - Internal inconsistency error in vol
* Hpe3parSdk::HTTPForbidden
- VV_IS_BEING_REMOVED - The volume is being removed
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VOLUME - The volume does not exists
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_SYS_VOLUME - Illegal op on system vol
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_INTERNAL_VOLUME - Illegal op on internal vol
|
[
"Returns",
"an",
"array",
"of",
"every",
"VolumeSet",
"the",
"given",
"volume",
"is",
"a",
"part",
"of",
".",
"The",
"array",
"can",
"contain",
"zero",
"one",
"or",
"multiple",
"items",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1776-L1783
|
20,789
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_volume_sets
|
def get_volume_sets
begin
@volume_set.get_volume_sets
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_volume_sets
begin
@volume_set.get_volume_sets
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_volume_sets",
"begin",
"@volume_set",
".",
"get_volume_sets",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets the Volume Sets
==== Returns
Array of VolumeSet
|
[
"Gets",
"the",
"Volume",
"Sets"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1790-L1797
|
20,790
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_volume_set
|
def get_volume_set(name)
begin
@volume_set.get_volume_set(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_volume_set(name)
begin
@volume_set.get_volume_set(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_volume_set",
"(",
"name",
")",
"begin",
"@volume_set",
".",
"get_volume_set",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets the information about a Volume Set.
==== Attributes
* name - The name of the CPG to find
type name: String
==== Returns
VolumeSet
==== Raises
* Hpe3parSdk::HPE3PARException
Error with code: 102 message: Set does not exist
|
[
"Gets",
"the",
"information",
"about",
"a",
"Volume",
"Set",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1814-L1821
|
20,791
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.create_volume_set
|
def create_volume_set(name, domain = nil, comment = nil, setmembers = nil)
begin
@volume_set.create_volume_set(name, domain, comment, setmembers)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def create_volume_set(name, domain = nil, comment = nil, setmembers = nil)
begin
@volume_set.create_volume_set(name, domain, comment, setmembers)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"create_volume_set",
"(",
"name",
",",
"domain",
"=",
"nil",
",",
"comment",
"=",
"nil",
",",
"setmembers",
"=",
"nil",
")",
"begin",
"@volume_set",
".",
"create_volume_set",
"(",
"name",
",",
"domain",
",",
"comment",
",",
"setmembers",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Creates a new volume set
==== Attributes
* name - the volume set to create
type name: String
* domain: the domain where the set lives
type domain: String
* comment: the comment for the vv set
type comment: String
* setmembers: the vv(s) to add to the set, the existence of the vv(s) will not be checked
type name: Array of String
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT Invalid URI Syntax.
* Hpe3parSdk::HTTPBadRequest
- NON_EXISTENT_DOMAIN - Domain doesn't exist.
* Hpe3parSdk::HTTPBadRequest
- NO_SPACE - Not Enough space is available.
* Hpe3parSdk::HTTPBadRequest
- BAD_CPG_PATTERN A Pattern in a CPG specifies illegal values.
* Hpe3parSdk::HTTPForbidden
- PERM_DENIED - Permission denied
* Hpe3parSdk::HTTPConflict
- EXISTENT_CPG - CPG Exists already
|
[
"Creates",
"a",
"new",
"volume",
"set"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1850-L1857
|
20,792
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.delete_volume_set
|
def delete_volume_set(name)
begin
@volume_set.delete_volume_set(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def delete_volume_set(name)
begin
@volume_set.delete_volume_set(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"delete_volume_set",
"(",
"name",
")",
"begin",
"@volume_set",
".",
"delete_volume_set",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Deletes the volume set. You must clear all QOS rules before a volume set can be deleted.
==== Attributes
* name - The name of the VolumeSet
type name: String
==== Raises
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_SET - The set does not exists.
* Hpe3parSdk::HTTPConflict
- - EXPORTED_VLUN - The host set has exported VLUNs. The VV set was exported.
* Hpe3parSdk::HTTPConflict
- VVSET_QOS_TARGET - The object is already part of the set.
|
[
"Deletes",
"the",
"volume",
"set",
".",
"You",
"must",
"clear",
"all",
"QOS",
"rules",
"before",
"a",
"volume",
"set",
"can",
"be",
"deleted",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1874-L1881
|
20,793
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.modify_volume_set
|
def modify_volume_set(name, action = nil, newName = nil, comment = nil, flash_cache_policy = nil, setmembers = nil)
begin
@volume_set.modify_volume_set(name, action, newName, comment, flash_cache_policy, setmembers)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def modify_volume_set(name, action = nil, newName = nil, comment = nil, flash_cache_policy = nil, setmembers = nil)
begin
@volume_set.modify_volume_set(name, action, newName, comment, flash_cache_policy, setmembers)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"modify_volume_set",
"(",
"name",
",",
"action",
"=",
"nil",
",",
"newName",
"=",
"nil",
",",
"comment",
"=",
"nil",
",",
"flash_cache_policy",
"=",
"nil",
",",
"setmembers",
"=",
"nil",
")",
"begin",
"@volume_set",
".",
"modify_volume_set",
"(",
"name",
",",
"action",
",",
"newName",
",",
"comment",
",",
"flash_cache_policy",
",",
"setmembers",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Modifies a volume set by adding or removing a volume from the volume
set. It's actions is based on the enums MEM_ADD or MEM_REMOVE.
==== Attributes
* action: add or remove volume from the set
type name: Hpe3parSdk::SetCustomAction
* name: the volume set name
type name: String
* newName: new name of set
type newName: String
* comment: the comment for on the vv set
type comment: String
* flash_cache_policy: the flash-cache policy for the vv set
type flash_cache_policy: enum
* setmembers: the vv to add to the set, the existence of the vv will not be checked
type name: Array of String
==== Raises
* Hpe3parSdk::HTTPBadRequest
- EXISTENT_SET - The set already exits.
* Hpe3parSdk::HTTPBadRequest
- EXISTENT_SET - The set already exits.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_SET - The set does not exists.
* Hpe3parSdk::HTTPConflict
- MEMBER_IN_DOMAINSET - The host is in a domain set.
* Hpe3parSdk::HTTPConflict
- MEMBER_IN_SET - The object is already part of the set.
* Hpe3parSdk::HTTPNotFound
- MEMBER_NOT_IN_SET - The object is not part of the set.
* Hpe3parSdk::HTTPConflict
- MEMBER_NOT_IN_SAME_DOMAIN - Objects must be in the same domain to
perform this operation.
* Hpe3parSdk::HTTPForbidden
- VV_IN_INCONSISTENT_STATE - The volume has an internal
inconsistency error.
* Hpe3parSdk::HTTPForbidden
- VV_IS_BEING_REMOVED - The volume is being removed.
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VOLUME - The volume does not exists.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_SYS_VOLUME - The operation is not allowed on a
system volume.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_INTERNAL_VOLUME - The operation is not allowed
on an internal volume.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_DUP_NAME - Invalid input (duplicate name).
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_PARAM_CONFLICT - Invalid input (parameters cannot be
present at the same time).
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_ILLEGAL_CHAR - Invalid contains one or more illegal
characters.
|
[
"Modifies",
"a",
"volume",
"set",
"by",
"adding",
"or",
"removing",
"a",
"volume",
"from",
"the",
"volume",
"set",
".",
"It",
"s",
"actions",
"is",
"based",
"on",
"the",
"enums",
"MEM_ADD",
"or",
"MEM_REMOVE",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L1939-L1946
|
20,794
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.create_snapshot_of_volume_set
|
def create_snapshot_of_volume_set(name, copy_of_name, optional = nil)
begin
@volume_set.create_snapshot_of_volume_set(name, copy_of_name, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def create_snapshot_of_volume_set(name, copy_of_name, optional = nil)
begin
@volume_set.create_snapshot_of_volume_set(name, copy_of_name, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"create_snapshot_of_volume_set",
"(",
"name",
",",
"copy_of_name",
",",
"optional",
"=",
"nil",
")",
"begin",
"@volume_set",
".",
"create_snapshot_of_volume_set",
"(",
"name",
",",
"copy_of_name",
",",
"optional",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Creates a snapshot of an existing VolumeSet
==== Attributes
* name: Name of the Snapshot. The vvname pattern is described in "VV Name Patterns" in the HPE 3PAR Command Line Interface Reference, which is available at the following website: http://www.hp.com/go/storage/docs
type name: String
* copy_of_name: the name of the parent volume
type copy_of_name: String
* comment: the comment on the vv set
type comment: String
* optional: Hash of optional params
type optional: Hash
optional = {
'id' => 12, # Specifies ID of the volume set
# set, next by default
'comment' => "some comment",
'readOnly' => true, # Read Only
'expirationHours' => 36, # time from now to expire
'retentionHours' => 12 # time from now to expire
}
==== Raises
* Hpe3parSdk::HTTPBadRequest
- INVALID_INPUT_VV_PATTERN - Invalid volume pattern specified
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_SET - The set does not exists.
* Hpe3parSdk::HTTPNotFound
- EMPTY_SET - The set is empty
* Hpe3parSdk::HTTPServiceUnavailable
- VV_LIMIT_REACHED - Maximum number of volumes reached
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VOL - The storage volume does not exist
* Hpe3parSdk::HTTPForbidden
- VV_IS_BEING_REMOVED - The volume is being removed
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_READONLY_TO_READONLY_SNAP - Creating a read-only copy from a read-only volume is not permitted
* Hpe3parSdk::HTTPConflict
- NO_SNAP_CPG - No snapshot CPG has been configured for the volume
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_DUP_NAME - Invalid input (duplicate name).
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_SNAP_PARENT_SAME_BASE - Two parent snapshots share the same base volume
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_ONLINE_COPY_IN_PROGRESS - Invalid operation. Online copyis in progress
* Hpe3parSdk::HTTPServiceUnavailable
- VV_ID_LIMIT_REACHED - Max number of volumeIDs has been reached
* Hpe3parSdk::HTTPNotFound
- NON_EXISTENT_VOLUME - The volume does not exists
* Hpe3parSdk::HTTPForbidden
- VV_IN_STALE_STATE - The volume is in a stale state.
* Hpe3parSdk::HTTPForbidden
- VV_NOT_STARTED - Volume is not started
* Hpe3parSdk::HTTPForbidden
- VV_UNAVAILABLE - The volume is not accessible
* Hpe3parSdk::HTTPServiceUnavailable
- SNAPSHOT_LIMIT_REACHED - Max number of snapshots has been reached
* Hpe3parSdk::HTTPServiceUnavailable
- CPG_ALLOCATION_WARNING_REACHED - The CPG has reached the allocation warning
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_VOLUME_CONV_IN_PROGRESS - Invalid operation: VV conversion is in progress.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_CLEANUP_IN_PROGRESS - Internal volume cleanup is in progress.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_PEER_VOLUME - Cannot modify a peer volume.
* Hpe3parSdk::HTTPConflict
- INV_OPERATION_VV_VOLUME_CONV_IN_PROGRESS - INV_OPERATION_VV_ONLINE_COPY_IN_PROGRESS - The volume is the target of an online copy.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_INTERNAL_VOLUME - Illegal op on internal vol
* Hpe3parSdk::HTTPConflict
- EXISTENT_ID - An ID exists
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_VV_NOT_IN_NORMAL_STATE - Volume state is not normal
* Hpe3parSdk::HTTPForbidden
- VV_IN_INCONSISTENT_STATE - Internal inconsistency error in vol
* Hpe3parSdk::HTTPBadRequest
- INVALID_INPUT_VV_PATTERN - - INV_INPUT_RETAIN_GT_EXPIRE - Retention time is greater than expiration time.
* Hpe3parSdk::HTTPBadRequest
- INV_INPUT_TIME - Invalid time specified.
* Hpe3parSdk::HTTPForbidden
- INV_OPERATION_SNAPSHOT_NOT_SAME_TYPE - Some snapshots in the volume set are read-only, some are read-write
|
[
"Creates",
"a",
"snapshot",
"of",
"an",
"existing",
"VolumeSet"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2064-L2071
|
20,795
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.create_snapshot
|
def create_snapshot(name, copy_of_name, optional = nil)
if @current_version < @min_version_with_compression && !optional.nil?
optional.delete_if { |key, _value| key == :allowRemoteCopyParent }
end
begin
@volume.create_snapshot(name, copy_of_name, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def create_snapshot(name, copy_of_name, optional = nil)
if @current_version < @min_version_with_compression && !optional.nil?
optional.delete_if { |key, _value| key == :allowRemoteCopyParent }
end
begin
@volume.create_snapshot(name, copy_of_name, optional)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"create_snapshot",
"(",
"name",
",",
"copy_of_name",
",",
"optional",
"=",
"nil",
")",
"if",
"@current_version",
"<",
"@min_version_with_compression",
"&&",
"!",
"optional",
".",
"nil?",
"optional",
".",
"delete_if",
"{",
"|",
"key",
",",
"_value",
"|",
"key",
"==",
":allowRemoteCopyParent",
"}",
"end",
"begin",
"@volume",
".",
"create_snapshot",
"(",
"name",
",",
"copy_of_name",
",",
"optional",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Creates a snapshot of an existing Volume.
==== Attributes
* name - the name of the Snapshot
type name: String
* copy_of_name - the name of the parent volume
type copy_of_name: String
* optional - Hash of other optional items
type optional: Hash
optional = {
'id' => 12, # Specifies the ID of the volume,
# next by default
'comment' => "some comment",
'readOnly' => true, # Read Only
'expirationHours' => 36, # time from now to expire
'retentionHours' => 12 # time from now to expire
}
==== Raises
* Hpe3parSdk::HTTPNotFound
- INON_EXISTENT_VOL - The volume does not exist
* Hpe3parSdk::HTTPForbidden
- PERM_DENIED - Permission denied
|
[
"Creates",
"a",
"snapshot",
"of",
"an",
"existing",
"Volume",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2099-L2109
|
20,796
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_volume_snapshots
|
def get_volume_snapshots(name)
begin
@volume.get_volume_snapshots(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_volume_snapshots(name)
begin
@volume.get_volume_snapshots(name)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_volume_snapshots",
"(",
"name",
")",
"begin",
"@volume",
".",
"get_volume_snapshots",
"(",
"name",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets the snapshots of a particular volume
==== Attributes
* name - the name of the volume
type name: String
==== Returns
Array of VirtualVolume
|
[
"Gets",
"the",
"snapshots",
"of",
"a",
"particular",
"volume"
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2192-L2199
|
20,797
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_ports
|
def get_ports
begin
@port.get_ports
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_ports
begin
@port.get_ports
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_ports",
"begin",
"@port",
".",
"get_ports",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets an array of all ports on the 3PAR.
==== Returns
Array of Port.
|
[
"Gets",
"an",
"array",
"of",
"all",
"ports",
"on",
"the",
"3PAR",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2206-L2213
|
20,798
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_fc_ports
|
def get_fc_ports(state = nil)
begin
@port.get_fc_ports(state)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_fc_ports(state = nil)
begin
@port.get_fc_ports(state)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_fc_ports",
"(",
"state",
"=",
"nil",
")",
"begin",
"@port",
".",
"get_fc_ports",
"(",
"state",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets an array of Fibre Channel Ports.
* state - Port link state.
type name: Integer. Refer Hpe3parSdk::PortLinkState for complete enumeration.
==== Returns
Array of Fibre Channel Port.
|
[
"Gets",
"an",
"array",
"of",
"Fibre",
"Channel",
"Ports",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2223-L2230
|
20,799
|
HewlettPackard/hpe3par_ruby_sdk
|
lib/Hpe3parSdk/client.rb
|
Hpe3parSdk.Client.get_iscsi_ports
|
def get_iscsi_ports(state = nil)
begin
@port.get_iscsi_ports(state)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
ruby
|
def get_iscsi_ports(state = nil)
begin
@port.get_iscsi_ports(state)
rescue => ex
Util.log_exception(ex, caller_locations(1, 1)[0].label)
raise ex
end
end
|
[
"def",
"get_iscsi_ports",
"(",
"state",
"=",
"nil",
")",
"begin",
"@port",
".",
"get_iscsi_ports",
"(",
"state",
")",
"rescue",
"=>",
"ex",
"Util",
".",
"log_exception",
"(",
"ex",
",",
"caller_locations",
"(",
"1",
",",
"1",
")",
"[",
"0",
"]",
".",
"label",
")",
"raise",
"ex",
"end",
"end"
] |
Gets an array of iSCSI Ports.
* state - Port link state.
type name: Integer. Refer Hpe3parSdk::PortLinkState for complete enumeration.
==== Returns
Array of iSCSI Port.
|
[
"Gets",
"an",
"array",
"of",
"iSCSI",
"Ports",
"."
] |
f8cfc6e597741be593cf7fe013accadf982ee68b
|
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2240-L2247
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.