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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
15,800
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/webhook.rb
|
JSS.WebHook.event=
|
def event=(new_val)
return nil if new_val == @event
raise JSS::InvalidDataError, 'Unknown webhook event' unless EVENTS.include? new_val
@event = new_val
@need_to_update = true
end
|
ruby
|
def event=(new_val)
return nil if new_val == @event
raise JSS::InvalidDataError, 'Unknown webhook event' unless EVENTS.include? new_val
@event = new_val
@need_to_update = true
end
|
[
"def",
"event",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@event",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Unknown webhook event'",
"unless",
"EVENTS",
".",
"include?",
"new_val",
"@event",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set the event handled by this webhook
Must be a member of the EVENTS Array
@param new_val[String] The event name
@return [void]
|
[
"Set",
"the",
"event",
"handled",
"by",
"this",
"webhook",
"Must",
"be",
"a",
"member",
"of",
"the",
"EVENTS",
"Array"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/webhook.rb#L185-L190
|
15,801
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/webhook.rb
|
JSS.WebHook.rest_xml
|
def rest_xml
validate_before_save
doc = REXML::Document.new APIConnection::XML_HEADER
webhook = doc.add_element 'webhook'
webhook.add_element('name').text = @name
webhook.add_element('enabled').text = @enabled
webhook.add_element('url').text = @url
webhook.add_element('content_type').text = CONTENT_TYPES[@content_type]
webhook.add_element('event').text = @event
doc.to_s
end
|
ruby
|
def rest_xml
validate_before_save
doc = REXML::Document.new APIConnection::XML_HEADER
webhook = doc.add_element 'webhook'
webhook.add_element('name').text = @name
webhook.add_element('enabled').text = @enabled
webhook.add_element('url').text = @url
webhook.add_element('content_type').text = CONTENT_TYPES[@content_type]
webhook.add_element('event').text = @event
doc.to_s
end
|
[
"def",
"rest_xml",
"validate_before_save",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"APIConnection",
"::",
"XML_HEADER",
"webhook",
"=",
"doc",
".",
"add_element",
"'webhook'",
"webhook",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"@name",
"webhook",
".",
"add_element",
"(",
"'enabled'",
")",
".",
"text",
"=",
"@enabled",
"webhook",
".",
"add_element",
"(",
"'url'",
")",
".",
"text",
"=",
"@url",
"webhook",
".",
"add_element",
"(",
"'content_type'",
")",
".",
"text",
"=",
"CONTENT_TYPES",
"[",
"@content_type",
"]",
"webhook",
".",
"add_element",
"(",
"'event'",
")",
".",
"text",
"=",
"@event",
"doc",
".",
"to_s",
"end"
] |
Return the REST XML for this webhook, with the current values,
for saving or updating
|
[
"Return",
"the",
"REST",
"XML",
"for",
"this",
"webhook",
"with",
"the",
"current",
"values",
"for",
"saving",
"or",
"updating"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/webhook.rb#L228-L238
|
15,802
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/computer_invitation.rb
|
JSS.ComputerInvitation.create
|
def create
new_invitation_id = super
jss_me = ComputerInvitation.fetch(id: new_invitation_id, name: 'set_by_request')
@name = jss_me.name
@invitation_type = jss_me.invitation_type
@create_account_if_does_not_exist = jss_me.create_account_if_does_not_exist
@expiration_date_epoch = jss_me.expiration_date_epoch
@ssh_username = jss_me.ssh_username
@hide_account = jss_me.hide_account
@invitation_status = jss_me.invitation_status
@multiple_uses_allowed = jss_me.multiple_uses_allowed
end
|
ruby
|
def create
new_invitation_id = super
jss_me = ComputerInvitation.fetch(id: new_invitation_id, name: 'set_by_request')
@name = jss_me.name
@invitation_type = jss_me.invitation_type
@create_account_if_does_not_exist = jss_me.create_account_if_does_not_exist
@expiration_date_epoch = jss_me.expiration_date_epoch
@ssh_username = jss_me.ssh_username
@hide_account = jss_me.hide_account
@invitation_status = jss_me.invitation_status
@multiple_uses_allowed = jss_me.multiple_uses_allowed
end
|
[
"def",
"create",
"new_invitation_id",
"=",
"super",
"jss_me",
"=",
"ComputerInvitation",
".",
"fetch",
"(",
"id",
":",
"new_invitation_id",
",",
"name",
":",
"'set_by_request'",
")",
"@name",
"=",
"jss_me",
".",
"name",
"@invitation_type",
"=",
"jss_me",
".",
"invitation_type",
"@create_account_if_does_not_exist",
"=",
"jss_me",
".",
"create_account_if_does_not_exist",
"@expiration_date_epoch",
"=",
"jss_me",
".",
"expiration_date_epoch",
"@ssh_username",
"=",
"jss_me",
".",
"ssh_username",
"@hide_account",
"=",
"jss_me",
".",
"hide_account",
"@invitation_status",
"=",
"jss_me",
".",
"invitation_status",
"@multiple_uses_allowed",
"=",
"jss_me",
".",
"multiple_uses_allowed",
"end"
] |
Public Instance Methods
@see APIObject#initialize
Public Class Methods
Needed to support creation of new Computer Invitations to set their name.
@return [JSS::ComputerInvitation]
|
[
"Public",
"Instance",
"Methods"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/computer_invitation.rb#L172-L184
|
15,803
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/computer_invitation.rb
|
JSS.ComputerInvitation.rest_xml
|
def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
obj = doc.add_element RSRC_OBJECT_KEY.to_s
obj.add_element('invitation_type').text = invitation_type
obj.add_element('create_account_if_does_not_exist').text = create_account_if_does_not_exist
if expiration_date_epoch
obj.add_element('expiration_date_epoch').text = expiration_date_epoch
end
obj.add_element('ssh_username').text = ssh_username
obj.add_element('hide_account').text = hide_account
obj.add_element('invitation_status').text = invitation_status
obj.add_element('multiple_uses_allowed').text = multiple_uses_allowed
add_site_to_xml(doc)
doc.to_s
end
|
ruby
|
def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
obj = doc.add_element RSRC_OBJECT_KEY.to_s
obj.add_element('invitation_type').text = invitation_type
obj.add_element('create_account_if_does_not_exist').text = create_account_if_does_not_exist
if expiration_date_epoch
obj.add_element('expiration_date_epoch').text = expiration_date_epoch
end
obj.add_element('ssh_username').text = ssh_username
obj.add_element('hide_account').text = hide_account
obj.add_element('invitation_status').text = invitation_status
obj.add_element('multiple_uses_allowed').text = multiple_uses_allowed
add_site_to_xml(doc)
doc.to_s
end
|
[
"def",
"rest_xml",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"APIConnection",
"::",
"XML_HEADER",
"obj",
"=",
"doc",
".",
"add_element",
"RSRC_OBJECT_KEY",
".",
"to_s",
"obj",
".",
"add_element",
"(",
"'invitation_type'",
")",
".",
"text",
"=",
"invitation_type",
"obj",
".",
"add_element",
"(",
"'create_account_if_does_not_exist'",
")",
".",
"text",
"=",
"create_account_if_does_not_exist",
"if",
"expiration_date_epoch",
"obj",
".",
"add_element",
"(",
"'expiration_date_epoch'",
")",
".",
"text",
"=",
"expiration_date_epoch",
"end",
"obj",
".",
"add_element",
"(",
"'ssh_username'",
")",
".",
"text",
"=",
"ssh_username",
"obj",
".",
"add_element",
"(",
"'hide_account'",
")",
".",
"text",
"=",
"hide_account",
"obj",
".",
"add_element",
"(",
"'invitation_status'",
")",
".",
"text",
"=",
"invitation_status",
"obj",
".",
"add_element",
"(",
"'multiple_uses_allowed'",
")",
".",
"text",
"=",
"multiple_uses_allowed",
"add_site_to_xml",
"(",
"doc",
")",
"doc",
".",
"to_s",
"end"
] |
Sets invitation expiration 4 hours after request.
|
[
"Sets",
"invitation",
"expiration",
"4",
"hours",
"after",
"request",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/computer_invitation.rb#L192-L206
|
15,804
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable/icon.rb
|
JSS.Icon.save
|
def save(path, overwrite = false)
path = Pathname.new path
path = path + @name if path.directory? && @name
raise JSS::AlreadyExistsError, "The file #{path} already exists" if path.exist? unless overwrite
path.delete if path.exist?
path.jss_save @data
end
|
ruby
|
def save(path, overwrite = false)
path = Pathname.new path
path = path + @name if path.directory? && @name
raise JSS::AlreadyExistsError, "The file #{path} already exists" if path.exist? unless overwrite
path.delete if path.exist?
path.jss_save @data
end
|
[
"def",
"save",
"(",
"path",
",",
"overwrite",
"=",
"false",
")",
"path",
"=",
"Pathname",
".",
"new",
"path",
"path",
"=",
"path",
"+",
"@name",
"if",
"path",
".",
"directory?",
"&&",
"@name",
"raise",
"JSS",
"::",
"AlreadyExistsError",
",",
"\"The file #{path} already exists\"",
"if",
"path",
".",
"exist?",
"unless",
"overwrite",
"path",
".",
"delete",
"if",
"path",
".",
"exist?",
"path",
".",
"jss_save",
"@data",
"end"
] |
Save the icon to a file.
@param path[Pathname, String] The path to which the file should be saved.
If the path given is an existing directory, the icon's current filename will
be used, if known.
@param overwrite[Boolean] Overwrite the file if it exists? Defaults to false
@return [void]
|
[
"Save",
"the",
"icon",
"to",
"a",
"file",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable/icon.rb#L177-L184
|
15,805
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/categorizable.rb
|
JSS.Categorizable.category=
|
def category=(new_cat)
return nil unless updatable? || creatable?
# unset the category? Use nil or an empty string
if NON_CATEGORIES.include? new_cat
unset_category
return
end
new_name, new_id = evaluate_new_category(new_cat)
# no change, go home.
return nil if new_name == @category_name
raise JSS::NoSuchItemError, "Category '#{new_cat}' is not known to the JSS" unless JSS::Category.all_names(:ref, api: @api).include? new_name
@category_name = new_name
@category_id = new_id
@need_to_update = true
end
|
ruby
|
def category=(new_cat)
return nil unless updatable? || creatable?
# unset the category? Use nil or an empty string
if NON_CATEGORIES.include? new_cat
unset_category
return
end
new_name, new_id = evaluate_new_category(new_cat)
# no change, go home.
return nil if new_name == @category_name
raise JSS::NoSuchItemError, "Category '#{new_cat}' is not known to the JSS" unless JSS::Category.all_names(:ref, api: @api).include? new_name
@category_name = new_name
@category_id = new_id
@need_to_update = true
end
|
[
"def",
"category",
"=",
"(",
"new_cat",
")",
"return",
"nil",
"unless",
"updatable?",
"||",
"creatable?",
"# unset the category? Use nil or an empty string",
"if",
"NON_CATEGORIES",
".",
"include?",
"new_cat",
"unset_category",
"return",
"end",
"new_name",
",",
"new_id",
"=",
"evaluate_new_category",
"(",
"new_cat",
")",
"# no change, go home.",
"return",
"nil",
"if",
"new_name",
"==",
"@category_name",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"Category '#{new_cat}' is not known to the JSS\"",
"unless",
"JSS",
"::",
"Category",
".",
"all_names",
"(",
":ref",
",",
"api",
":",
"@api",
")",
".",
"include?",
"new_name",
"@category_name",
"=",
"new_name",
"@category_id",
"=",
"new_id",
"@need_to_update",
"=",
"true",
"end"
] |
Change the category of this object.
Any of the NON_CATEGORIES values will
unset the category
@param new_cat[Integer, String] The new category
@return [void]
|
[
"Change",
"the",
"category",
"of",
"this",
"object",
".",
"Any",
"of",
"the",
"NON_CATEGORIES",
"values",
"will",
"unset",
"the",
"category"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/categorizable.rb#L132-L151
|
15,806
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/categorizable.rb
|
JSS.Categorizable.parse_category
|
def parse_category
cat =
if self.class::CATEGORY_SUBSET == :top
@init_data[:category]
else
@init_data[self.class::CATEGORY_SUBSET][:category]
end
if cat.is_a? String
@category_name = cat
@category_id = JSS::Category.category_id_from_name @category_name
else
@category_name = cat[:name]
@category_id = cat[:id]
end
clean_raw_categories
end
|
ruby
|
def parse_category
cat =
if self.class::CATEGORY_SUBSET == :top
@init_data[:category]
else
@init_data[self.class::CATEGORY_SUBSET][:category]
end
if cat.is_a? String
@category_name = cat
@category_id = JSS::Category.category_id_from_name @category_name
else
@category_name = cat[:name]
@category_id = cat[:id]
end
clean_raw_categories
end
|
[
"def",
"parse_category",
"cat",
"=",
"if",
"self",
".",
"class",
"::",
"CATEGORY_SUBSET",
"==",
":top",
"@init_data",
"[",
":category",
"]",
"else",
"@init_data",
"[",
"self",
".",
"class",
"::",
"CATEGORY_SUBSET",
"]",
"[",
":category",
"]",
"end",
"if",
"cat",
".",
"is_a?",
"String",
"@category_name",
"=",
"cat",
"@category_id",
"=",
"JSS",
"::",
"Category",
".",
"category_id_from_name",
"@category_name",
"else",
"@category_name",
"=",
"cat",
"[",
":name",
"]",
"@category_id",
"=",
"cat",
"[",
":id",
"]",
"end",
"clean_raw_categories",
"end"
] |
Parse the category data from any incoming API data
@return [void] description_of_returned_object
|
[
"Parse",
"the",
"category",
"data",
"from",
"any",
"incoming",
"API",
"data"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/categorizable.rb#L191-L207
|
15,807
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/categorizable.rb
|
JSS.Categorizable.add_category_to_xml
|
def add_category_to_xml(xmldoc)
return if category_name.to_s.empty?
cat_elem = REXML::Element.new('category')
if self.class::CATEGORY_DATA_TYPE == String
cat_elem.text = @category_name.to_s
elsif self.class::CATEGORY_DATA_TYPE == Hash
cat_elem.add_element('name').text = @category_name.to_s
else
raise JSS::InvalidDataError, "Uknown CATEGORY_DATA_TYPE for class #{self.class}"
end
root = xmldoc.root
if self.class::CATEGORY_SUBSET == :top
root.add_element cat_elem
return
end
parent = root.elements[self.class::CATEGORY_SUBSET.to_s]
parent ||= root.add_element self.class::CATEGORY_SUBSET.to_s
parent.add_element cat_elem
end
|
ruby
|
def add_category_to_xml(xmldoc)
return if category_name.to_s.empty?
cat_elem = REXML::Element.new('category')
if self.class::CATEGORY_DATA_TYPE == String
cat_elem.text = @category_name.to_s
elsif self.class::CATEGORY_DATA_TYPE == Hash
cat_elem.add_element('name').text = @category_name.to_s
else
raise JSS::InvalidDataError, "Uknown CATEGORY_DATA_TYPE for class #{self.class}"
end
root = xmldoc.root
if self.class::CATEGORY_SUBSET == :top
root.add_element cat_elem
return
end
parent = root.elements[self.class::CATEGORY_SUBSET.to_s]
parent ||= root.add_element self.class::CATEGORY_SUBSET.to_s
parent.add_element cat_elem
end
|
[
"def",
"add_category_to_xml",
"(",
"xmldoc",
")",
"return",
"if",
"category_name",
".",
"to_s",
".",
"empty?",
"cat_elem",
"=",
"REXML",
"::",
"Element",
".",
"new",
"(",
"'category'",
")",
"if",
"self",
".",
"class",
"::",
"CATEGORY_DATA_TYPE",
"==",
"String",
"cat_elem",
".",
"text",
"=",
"@category_name",
".",
"to_s",
"elsif",
"self",
".",
"class",
"::",
"CATEGORY_DATA_TYPE",
"==",
"Hash",
"cat_elem",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"@category_name",
".",
"to_s",
"else",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"Uknown CATEGORY_DATA_TYPE for class #{self.class}\"",
"end",
"root",
"=",
"xmldoc",
".",
"root",
"if",
"self",
".",
"class",
"::",
"CATEGORY_SUBSET",
"==",
":top",
"root",
".",
"add_element",
"cat_elem",
"return",
"end",
"parent",
"=",
"root",
".",
"elements",
"[",
"self",
".",
"class",
"::",
"CATEGORY_SUBSET",
".",
"to_s",
"]",
"parent",
"||=",
"root",
".",
"add_element",
"self",
".",
"class",
"::",
"CATEGORY_SUBSET",
".",
"to_s",
"parent",
".",
"add_element",
"cat_elem",
"end"
] |
Add the category to the XML for POSTing or PUTting to the API.
@param xmldoc[REXML::Document] The in-construction XML document
@return [void]
|
[
"Add",
"the",
"category",
"to",
"the",
"XML",
"for",
"POSTing",
"or",
"PUTting",
"to",
"the",
"API",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/categorizable.rb#L221-L243
|
15,808
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/scopable.rb
|
JSS.Scopable.scope=
|
def scope= (new_scope)
raise JSS::InvalidDataError, "JSS::Scopable::Scope instance required" unless new_criteria.kind_of?(JSS::Scopable::Scope)
raise JSS::InvalidDataError, "Scope object must have target_key of :#{self.class::SCOPE_TARGET_KEY}" unless self.class::SCOPE_TARGET_KEY == new_scope.target_key
@scope = new_scope
@need_to_update = true
end
|
ruby
|
def scope= (new_scope)
raise JSS::InvalidDataError, "JSS::Scopable::Scope instance required" unless new_criteria.kind_of?(JSS::Scopable::Scope)
raise JSS::InvalidDataError, "Scope object must have target_key of :#{self.class::SCOPE_TARGET_KEY}" unless self.class::SCOPE_TARGET_KEY == new_scope.target_key
@scope = new_scope
@need_to_update = true
end
|
[
"def",
"scope",
"=",
"(",
"new_scope",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"JSS::Scopable::Scope instance required\"",
"unless",
"new_criteria",
".",
"kind_of?",
"(",
"JSS",
"::",
"Scopable",
"::",
"Scope",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"Scope object must have target_key of :#{self.class::SCOPE_TARGET_KEY}\"",
"unless",
"self",
".",
"class",
"::",
"SCOPE_TARGET_KEY",
"==",
"new_scope",
".",
"target_key",
"@scope",
"=",
"new_scope",
"@need_to_update",
"=",
"true",
"end"
] |
Change the scope
@param new_scope[JSS::Scopable::Scope] the new scope
@return [void]
|
[
"Change",
"the",
"scope"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/scopable.rb#L98-L103
|
15,809
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mdm.rb
|
JSS.MDM.erase_device
|
def erase_device(passcode = '', preserve_data_plan: false)
self.class.erase_device @id, passcode: passcode, preserve_data_plan: preserve_data_plan, api: @api
end
|
ruby
|
def erase_device(passcode = '', preserve_data_plan: false)
self.class.erase_device @id, passcode: passcode, preserve_data_plan: preserve_data_plan, api: @api
end
|
[
"def",
"erase_device",
"(",
"passcode",
"=",
"''",
",",
"preserve_data_plan",
":",
"false",
")",
"self",
".",
"class",
".",
"erase_device",
"@id",
",",
"passcode",
":",
"passcode",
",",
"preserve_data_plan",
":",
"preserve_data_plan",
",",
"api",
":",
"@api",
"end"
] |
Send an erase device command to this object
@param passcode[String] a six-char passcode, required for computers & computergroups
@return (see .send_mdm_command)
|
[
"Send",
"an",
"erase",
"device",
"command",
"to",
"this",
"object"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mdm.rb#L1033-L1035
|
15,810
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mdm.rb
|
JSS.MDM.wallpaper
|
def wallpaper(wallpaper_setting: nil, wallpaper_content: nil, wallpaper_id: nil)
self.class.wallpaper(
@id,
wallpaper_setting: wallpaper_setting,
wallpaper_content: wallpaper_content,
wallpaper_id: wallpaper_id,
api: @api
)
end
|
ruby
|
def wallpaper(wallpaper_setting: nil, wallpaper_content: nil, wallpaper_id: nil)
self.class.wallpaper(
@id,
wallpaper_setting: wallpaper_setting,
wallpaper_content: wallpaper_content,
wallpaper_id: wallpaper_id,
api: @api
)
end
|
[
"def",
"wallpaper",
"(",
"wallpaper_setting",
":",
"nil",
",",
"wallpaper_content",
":",
"nil",
",",
"wallpaper_id",
":",
"nil",
")",
"self",
".",
"class",
".",
"wallpaper",
"(",
"@id",
",",
"wallpaper_setting",
":",
"wallpaper_setting",
",",
"wallpaper_content",
":",
"wallpaper_content",
",",
"wallpaper_id",
":",
"wallpaper_id",
",",
"api",
":",
"@api",
")",
"end"
] |
Send a wallpaper command to this object
@param wallpaper_setting[Symbol] :lock_screen, :home_screen, or :lock_and_home_screen
@param wallpaper_content[String,Pathname] The local path to a .png or .jpg to use
as the walpaper image, required if no wallpaper_id
@param wallpaper_id[Symbol] The id of an Icon in Jamf Pro to use as the wallpaper image,
required if no wallpaper_content
@return (see .send_mdm_command)
|
[
"Send",
"a",
"wallpaper",
"command",
"to",
"this",
"object"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mdm.rb#L1171-L1179
|
15,811
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mdm.rb
|
JSS.MDM.enable_lost_mode
|
def enable_lost_mode(
message: nil,
phone_number: nil,
footnote: nil,
enforce_lost_mode: true,
play_sound: false
)
self.class.enable_lost_mode(
@id,
message: message,
phone_number: phone_number,
footnote: footnote,
play_sound: play_sound,
enforce_lost_mode: enforce_lost_mode,
api: @api
)
end
|
ruby
|
def enable_lost_mode(
message: nil,
phone_number: nil,
footnote: nil,
enforce_lost_mode: true,
play_sound: false
)
self.class.enable_lost_mode(
@id,
message: message,
phone_number: phone_number,
footnote: footnote,
play_sound: play_sound,
enforce_lost_mode: enforce_lost_mode,
api: @api
)
end
|
[
"def",
"enable_lost_mode",
"(",
"message",
":",
"nil",
",",
"phone_number",
":",
"nil",
",",
"footnote",
":",
"nil",
",",
"enforce_lost_mode",
":",
"true",
",",
"play_sound",
":",
"false",
")",
"self",
".",
"class",
".",
"enable_lost_mode",
"(",
"@id",
",",
"message",
":",
"message",
",",
"phone_number",
":",
"phone_number",
",",
"footnote",
":",
"footnote",
",",
"play_sound",
":",
"play_sound",
",",
"enforce_lost_mode",
":",
"enforce_lost_mode",
",",
"api",
":",
"@api",
")",
"end"
] |
Send a enable_lost_mode command to one or more targets
Either or both of message and phone number must be provided
@param message[String] The message to display on the lock screen
@param phone_number[String] The phone number to display on the lock screen
@param footnote[String] Optional footnote to display on the lock screen
@param play_sound[Boolean] Play a sound when entering lost mode
@param enforce_lost_mode[Boolean] Re-enabled lost mode when re-enrolled after wipe.
@return (see .send_mdm_command)
|
[
"Send",
"a",
"enable_lost_mode",
"command",
"to",
"one",
"or",
"more",
"targets"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mdm.rb#L1260-L1276
|
15,812
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.frequency=
|
def frequency=(freq)
raise JSS::InvalidDataError, "New frequency must be one of :#{FREQUENCIES.keys.join ', :'}" unless FREQUENCIES.key?(freq)
@frequency = FREQUENCIES[freq]
@need_to_update = true
end
|
ruby
|
def frequency=(freq)
raise JSS::InvalidDataError, "New frequency must be one of :#{FREQUENCIES.keys.join ', :'}" unless FREQUENCIES.key?(freq)
@frequency = FREQUENCIES[freq]
@need_to_update = true
end
|
[
"def",
"frequency",
"=",
"(",
"freq",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"New frequency must be one of :#{FREQUENCIES.keys.join ', :'}\"",
"unless",
"FREQUENCIES",
".",
"key?",
"(",
"freq",
")",
"@frequency",
"=",
"FREQUENCIES",
"[",
"freq",
"]",
"@need_to_update",
"=",
"true",
"end"
] |
Set a new frequency for this policy.
@param freq[Symbol] the desired frequency, must be one of the keys of {FREQUENCIES}
@return [void]
|
[
"Set",
"a",
"new",
"frequency",
"for",
"this",
"policy",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L718-L722
|
15,813
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.target_drive=
|
def target_drive=(path_to_drive)
raise JSS::InvalidDataError, 'Path to target drive must be absolute' unless path_to_drive.to_s.start_with? '/'
@target_drive = path_to_drive.to_s
@need_to_update = true
end
|
ruby
|
def target_drive=(path_to_drive)
raise JSS::InvalidDataError, 'Path to target drive must be absolute' unless path_to_drive.to_s.start_with? '/'
@target_drive = path_to_drive.to_s
@need_to_update = true
end
|
[
"def",
"target_drive",
"=",
"(",
"path_to_drive",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Path to target drive must be absolute'",
"unless",
"path_to_drive",
".",
"to_s",
".",
"start_with?",
"'/'",
"@target_drive",
"=",
"path_to_drive",
".",
"to_s",
"@need_to_update",
"=",
"true",
"end"
] |
Set a new target drive for this policy.
@param path_to_drive[String,Pathname] the full path to the target drive, must start with a '/'
@return [void]
|
[
"Set",
"a",
"new",
"target",
"drive",
"for",
"this",
"policy",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L730-L734
|
15,814
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.offline=
|
def offline=(new_val)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? new_val
@offline = new_val
@need_to_update = true
end
|
ruby
|
def offline=(new_val)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? new_val
@offline = new_val
@need_to_update = true
end
|
[
"def",
"offline",
"=",
"(",
"new_val",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be boolean true or false'",
"unless",
"JSS",
"::",
"TRUE_FALSE",
".",
"include?",
"new_val",
"@offline",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set whether this policy is available offline.
@param new_val[Boolean]
@return [void]
|
[
"Set",
"whether",
"this",
"policy",
"is",
"available",
"offline",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L742-L746
|
15,815
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.set_trigger_event
|
def set_trigger_event(type, new_val)
raise JSS::InvalidDataError, "Trigger type must be one of #{TRIGGER_EVENTS.keys.join(', ')}" unless TRIGGER_EVENTS.key?(type)
if type == :custom
raise JSS::InvalidDataError, 'Custom triggers must be Strings' unless new_val.is_a? String
else
raise JSS::InvalidDataError, 'Non-custom triggers must be true or false' unless JSS::TRUE_FALSE.include? new_val
end
@trigger_events[TRIGGER_EVENTS[type]] = new_val
@need_to_update = true
end
|
ruby
|
def set_trigger_event(type, new_val)
raise JSS::InvalidDataError, "Trigger type must be one of #{TRIGGER_EVENTS.keys.join(', ')}" unless TRIGGER_EVENTS.key?(type)
if type == :custom
raise JSS::InvalidDataError, 'Custom triggers must be Strings' unless new_val.is_a? String
else
raise JSS::InvalidDataError, 'Non-custom triggers must be true or false' unless JSS::TRUE_FALSE.include? new_val
end
@trigger_events[TRIGGER_EVENTS[type]] = new_val
@need_to_update = true
end
|
[
"def",
"set_trigger_event",
"(",
"type",
",",
"new_val",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"Trigger type must be one of #{TRIGGER_EVENTS.keys.join(', ')}\"",
"unless",
"TRIGGER_EVENTS",
".",
"key?",
"(",
"type",
")",
"if",
"type",
"==",
":custom",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Custom triggers must be Strings'",
"unless",
"new_val",
".",
"is_a?",
"String",
"else",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Non-custom triggers must be true or false'",
"unless",
"JSS",
"::",
"TRUE_FALSE",
".",
"include?",
"new_val",
"end",
"@trigger_events",
"[",
"TRIGGER_EVENTS",
"[",
"type",
"]",
"]",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Change a trigger event
@param type[Symbol] the type of trigger, one of the keys of {TRIGGER_EVENTS}
@param new_val[Boolean] whether the type of trigger is active or not.
@return [void]
|
[
"Change",
"a",
"trigger",
"event"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L756-L765
|
15,816
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.server_side_activation=
|
def server_side_activation=(activation)
raise JSS::InvalidDataError, 'Activation must be a Time' unless activation.is_a? Time
@server_side_limitations[:activation] = activation
@need_to_update = true
end
|
ruby
|
def server_side_activation=(activation)
raise JSS::InvalidDataError, 'Activation must be a Time' unless activation.is_a? Time
@server_side_limitations[:activation] = activation
@need_to_update = true
end
|
[
"def",
"server_side_activation",
"=",
"(",
"activation",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Activation must be a Time'",
"unless",
"activation",
".",
"is_a?",
"Time",
"@server_side_limitations",
"[",
":activation",
"]",
"=",
"activation",
"@need_to_update",
"=",
"true",
"end"
] |
Set Server Side Activation
@param activation[Time] Activation date and time
@return [void]
|
[
"Set",
"Server",
"Side",
"Activation"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L773-L777
|
15,817
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.server_side_expiration=
|
def server_side_expiration=(expiration)
raise JSS::InvalidDataError, 'Expiration must be a Time' unless expiration.is_a? Time
@server_side_limitations[:expiration] = expiration
@need_to_update = true
end
|
ruby
|
def server_side_expiration=(expiration)
raise JSS::InvalidDataError, 'Expiration must be a Time' unless expiration.is_a? Time
@server_side_limitations[:expiration] = expiration
@need_to_update = true
end
|
[
"def",
"server_side_expiration",
"=",
"(",
"expiration",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Expiration must be a Time'",
"unless",
"expiration",
".",
"is_a?",
"Time",
"@server_side_limitations",
"[",
":expiration",
"]",
"=",
"expiration",
"@need_to_update",
"=",
"true",
"end"
] |
Set Server Side Expiration
@param expiration[Time] Expiration date and time
@return [void]
|
[
"Set",
"Server",
"Side",
"Expiration"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L785-L789
|
15,818
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.user_logged_in=
|
def user_logged_in=(logged_in_option)
raise JSS::InvalidDataError, "user_logged_in options: #{USER_LOGGED_IN.join(', ')}" unless USER_LOGGED_IN.include? logged_in_option
@reboot_options[:user_logged_in] = logged_in_option
@need_to_update = true
end
|
ruby
|
def user_logged_in=(logged_in_option)
raise JSS::InvalidDataError, "user_logged_in options: #{USER_LOGGED_IN.join(', ')}" unless USER_LOGGED_IN.include? logged_in_option
@reboot_options[:user_logged_in] = logged_in_option
@need_to_update = true
end
|
[
"def",
"user_logged_in",
"=",
"(",
"logged_in_option",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"user_logged_in options: #{USER_LOGGED_IN.join(', ')}\"",
"unless",
"USER_LOGGED_IN",
".",
"include?",
"logged_in_option",
"@reboot_options",
"[",
":user_logged_in",
"]",
"=",
"logged_in_option",
"@need_to_update",
"=",
"true",
"end"
] |
What to do at reboot when there is a User Logged In
@param logged_in_option[String] Any one of the Strings from USER_LOGGED_IN
@return [void]
|
[
"What",
"to",
"do",
"at",
"reboot",
"when",
"there",
"is",
"a",
"User",
"Logged",
"In"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L879-L883
|
15,819
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.reboot_message=
|
def reboot_message=(message)
raise JSS::InvalidDataError, 'Reboot message must be a String' unless message.is_a? String
@reboot_options[:message] = message
@need_to_update = true
end
|
ruby
|
def reboot_message=(message)
raise JSS::InvalidDataError, 'Reboot message must be a String' unless message.is_a? String
@reboot_options[:message] = message
@need_to_update = true
end
|
[
"def",
"reboot_message",
"=",
"(",
"message",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Reboot message must be a String'",
"unless",
"message",
".",
"is_a?",
"String",
"@reboot_options",
"[",
":message",
"]",
"=",
"message",
"@need_to_update",
"=",
"true",
"end"
] |
Set Reboot Message
@param reboot_message[String] Text of Reboot Message
@return [void] description of returned object
|
[
"Set",
"Reboot",
"Message"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L891-L895
|
15,820
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.startup_disk=
|
def startup_disk=(startup_disk_option)
raise JSS::InvalidDataError, "#{startup_disk_option} is not a valid Startup Disk" unless startup_disk_option.is_a? String
@reboot_options[:startup_disk] = 'Specify Local Startup Disk'
self.specify_startup = startup_disk_option
@need_to_update = true
end
|
ruby
|
def startup_disk=(startup_disk_option)
raise JSS::InvalidDataError, "#{startup_disk_option} is not a valid Startup Disk" unless startup_disk_option.is_a? String
@reboot_options[:startup_disk] = 'Specify Local Startup Disk'
self.specify_startup = startup_disk_option
@need_to_update = true
end
|
[
"def",
"startup_disk",
"=",
"(",
"startup_disk_option",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"#{startup_disk_option} is not a valid Startup Disk\"",
"unless",
"startup_disk_option",
".",
"is_a?",
"String",
"@reboot_options",
"[",
":startup_disk",
"]",
"=",
"'Specify Local Startup Disk'",
"self",
".",
"specify_startup",
"=",
"startup_disk_option",
"@need_to_update",
"=",
"true",
"end"
] |
Set Startup Disk
Only Supports 'Specify Local Startup Disk' at the moment
@param startup_disk_option[String]
@return [void]
|
[
"Set",
"Startup",
"Disk",
"Only",
"Supports",
"Specify",
"Local",
"Startup",
"Disk",
"at",
"the",
"moment"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L905-L910
|
15,821
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.specify_startup=
|
def specify_startup=(startup_volume)
raise JSS::InvalidDataError, "#{startup_volume} is not a valid Startup Disk" unless startup_volume.is_a? String
@reboot_options[:specify_startup] = startup_volume
@need_to_update = true
end
|
ruby
|
def specify_startup=(startup_volume)
raise JSS::InvalidDataError, "#{startup_volume} is not a valid Startup Disk" unless startup_volume.is_a? String
@reboot_options[:specify_startup] = startup_volume
@need_to_update = true
end
|
[
"def",
"specify_startup",
"=",
"(",
"startup_volume",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"#{startup_volume} is not a valid Startup Disk\"",
"unless",
"startup_volume",
".",
"is_a?",
"String",
"@reboot_options",
"[",
":specify_startup",
"]",
"=",
"startup_volume",
"@need_to_update",
"=",
"true",
"end"
] |
Specify Startup Volume
Only Supports "Specify Local Startup Disk"
@param startup_volume[String] a Volume to reboot to
@return [void]
|
[
"Specify",
"Startup",
"Volume",
"Only",
"Supports",
"Specify",
"Local",
"Startup",
"Disk"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L919-L923
|
15,822
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.minutes_until_reboot=
|
def minutes_until_reboot=(minutes)
raise JSS::InvalidDataError, 'Minutes until reboot must be an Integer' unless minutes.is_a? Integer
@reboot_options[:minutes_until_reboot] = minutes
@need_to_update = true
end
|
ruby
|
def minutes_until_reboot=(minutes)
raise JSS::InvalidDataError, 'Minutes until reboot must be an Integer' unless minutes.is_a? Integer
@reboot_options[:minutes_until_reboot] = minutes
@need_to_update = true
end
|
[
"def",
"minutes_until_reboot",
"=",
"(",
"minutes",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Minutes until reboot must be an Integer'",
"unless",
"minutes",
".",
"is_a?",
"Integer",
"@reboot_options",
"[",
":minutes_until_reboot",
"]",
"=",
"minutes",
"@need_to_update",
"=",
"true",
"end"
] |
Reboot Options
Minutes Until Reboot
@param minutes[String] The number of minutes to delay prior to reboot
@return [void]
|
[
"Reboot",
"Options",
"Minutes",
"Until",
"Reboot"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L944-L948
|
15,823
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.run_command=
|
def run_command=(command)
raise JSS::InvalidDataError, 'Command to run must be a String' unless command.is_a? String
@files_processes[:run_command] = command
@need_to_update = true
end
|
ruby
|
def run_command=(command)
raise JSS::InvalidDataError, 'Command to run must be a String' unless command.is_a? String
@files_processes[:run_command] = command
@need_to_update = true
end
|
[
"def",
"run_command",
"=",
"(",
"command",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Command to run must be a String'",
"unless",
"command",
".",
"is_a?",
"String",
"@files_processes",
"[",
":run_command",
"]",
"=",
"command",
"@need_to_update",
"=",
"true",
"end"
] |
Set the unix shell command to be run on the client
@param command[String] the unix shell command to be run on the client
@return [void]
|
[
"Set",
"the",
"unix",
"shell",
"command",
"to",
"be",
"run",
"on",
"the",
"client"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L978-L982
|
15,824
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.set_search_for_process
|
def set_search_for_process(process, kill = false)
@files_processes[:search_for_process] = process.to_s
@files_processes[:kill_process] = kill ? true : false
@need_to_update = true
end
|
ruby
|
def set_search_for_process(process, kill = false)
@files_processes[:search_for_process] = process.to_s
@files_processes[:kill_process] = kill ? true : false
@need_to_update = true
end
|
[
"def",
"set_search_for_process",
"(",
"process",
",",
"kill",
"=",
"false",
")",
"@files_processes",
"[",
":search_for_process",
"]",
"=",
"process",
".",
"to_s",
"@files_processes",
"[",
":kill_process",
"]",
"=",
"kill",
"?",
"true",
":",
"false",
"@need_to_update",
"=",
"true",
"end"
] |
Set the process name to search for, and if it should be killed if found.
Setter methods (which end with =) can't easily take
multiple arguments, so we instead name them "set_blah_blah"
rather than "blah_blah="
@param process[String] the process name to search for
@param kill[Boolean] should be process be killed if found
@return [void]
|
[
"Set",
"the",
"process",
"name",
"to",
"search",
"for",
"and",
"if",
"it",
"should",
"be",
"killed",
"if",
"found",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1026-L1030
|
15,825
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.set_search_by_path
|
def set_search_by_path(path, delete = false)
raise JSS::InvalidDataError, 'Path to search for must be a String or a Pathname' unless path.is_a?(String) || path.is_a?(Pathname)
@files_processes[:search_by_path] = path.to_s
@files_processes[:delete_file] = delete ? true : false
@need_to_update = true
end
|
ruby
|
def set_search_by_path(path, delete = false)
raise JSS::InvalidDataError, 'Path to search for must be a String or a Pathname' unless path.is_a?(String) || path.is_a?(Pathname)
@files_processes[:search_by_path] = path.to_s
@files_processes[:delete_file] = delete ? true : false
@need_to_update = true
end
|
[
"def",
"set_search_by_path",
"(",
"path",
",",
"delete",
"=",
"false",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Path to search for must be a String or a Pathname'",
"unless",
"path",
".",
"is_a?",
"(",
"String",
")",
"||",
"path",
".",
"is_a?",
"(",
"Pathname",
")",
"@files_processes",
"[",
":search_by_path",
"]",
"=",
"path",
".",
"to_s",
"@files_processes",
"[",
":delete_file",
"]",
"=",
"delete",
"?",
"true",
":",
"false",
"@need_to_update",
"=",
"true",
"end"
] |
Set the path to search for, a String or Pathname, and whether or not to delete it if found.
Setter methods (which end with =) can't easily take
multiple arguments, so we instead name them "set_blah_blah"
rather than "blah_blah="
@param path[String,Pathname] the path to search for
@param delete[Boolean] should the path be deleted if found
@return [void]
|
[
"Set",
"the",
"path",
"to",
"search",
"for",
"a",
"String",
"or",
"Pathname",
"and",
"whether",
"or",
"not",
"to",
"delete",
"it",
"if",
"found",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1057-L1062
|
15,826
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.spotlight_search=
|
def spotlight_search=(term)
raise JSS::InvalidDataError, 'Spotlight search term must be a String' unless term.is_a? String
@files_processes[:spotlight_search] = term
@need_to_update = true
end
|
ruby
|
def spotlight_search=(term)
raise JSS::InvalidDataError, 'Spotlight search term must be a String' unless term.is_a? String
@files_processes[:spotlight_search] = term
@need_to_update = true
end
|
[
"def",
"spotlight_search",
"=",
"(",
"term",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Spotlight search term must be a String'",
"unless",
"term",
".",
"is_a?",
"String",
"@files_processes",
"[",
":spotlight_search",
"]",
"=",
"term",
"@need_to_update",
"=",
"true",
"end"
] |
Set the term to seach for using spotlight
@param term[String] the term to seach for using spotlight
@return [void]
|
[
"Set",
"the",
"term",
"to",
"seach",
"for",
"using",
"spotlight"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1076-L1080
|
15,827
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.locate_file=
|
def locate_file=(term)
raise JSS::InvalidDataError, 'Term to locate must be a String' unless term.is_a? String
@files_processes[:locate_file] = term
@need_to_update = true
end
|
ruby
|
def locate_file=(term)
raise JSS::InvalidDataError, 'Term to locate must be a String' unless term.is_a? String
@files_processes[:locate_file] = term
@need_to_update = true
end
|
[
"def",
"locate_file",
"=",
"(",
"term",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Term to locate must be a String'",
"unless",
"term",
".",
"is_a?",
"String",
"@files_processes",
"[",
":locate_file",
"]",
"=",
"term",
"@need_to_update",
"=",
"true",
"end"
] |
Set the term to seach for using the locate command
@param term[String] the term to seach for using the locate command
@return [void]
|
[
"Set",
"the",
"term",
"to",
"seach",
"for",
"using",
"the",
"locate",
"command"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1094-L1098
|
15,828
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.add_package
|
def add_package(identifier, **opts)
id = validate_package_opts(identifier, opts)
return nil if @packages.map { |p| p[:id] }.include? id
name = JSS::Package.map_all_ids_to(:name, api: @api)[id]
pkg_data = {
id: id,
name: name,
action: PACKAGE_ACTIONS[opts[:action]],
feu: opts[:feu],
fut: opts[:feu],
update_autorun: opts[:update_autorun]
}
@packages.insert opts[:position], pkg_data
@need_to_update = true
@packages
end
|
ruby
|
def add_package(identifier, **opts)
id = validate_package_opts(identifier, opts)
return nil if @packages.map { |p| p[:id] }.include? id
name = JSS::Package.map_all_ids_to(:name, api: @api)[id]
pkg_data = {
id: id,
name: name,
action: PACKAGE_ACTIONS[opts[:action]],
feu: opts[:feu],
fut: opts[:feu],
update_autorun: opts[:update_autorun]
}
@packages.insert opts[:position], pkg_data
@need_to_update = true
@packages
end
|
[
"def",
"add_package",
"(",
"identifier",
",",
"**",
"opts",
")",
"id",
"=",
"validate_package_opts",
"(",
"identifier",
",",
"opts",
")",
"return",
"nil",
"if",
"@packages",
".",
"map",
"{",
"|",
"p",
"|",
"p",
"[",
":id",
"]",
"}",
".",
"include?",
"id",
"name",
"=",
"JSS",
"::",
"Package",
".",
"map_all_ids_to",
"(",
":name",
",",
"api",
":",
"@api",
")",
"[",
"id",
"]",
"pkg_data",
"=",
"{",
"id",
":",
"id",
",",
"name",
":",
"name",
",",
"action",
":",
"PACKAGE_ACTIONS",
"[",
"opts",
"[",
":action",
"]",
"]",
",",
"feu",
":",
"opts",
"[",
":feu",
"]",
",",
"fut",
":",
"opts",
"[",
":feu",
"]",
",",
"update_autorun",
":",
"opts",
"[",
":update_autorun",
"]",
"}",
"@packages",
".",
"insert",
"opts",
"[",
":position",
"]",
",",
"pkg_data",
"@need_to_update",
"=",
"true",
"@packages",
"end"
] |
Add a package to the list of pkgs handled by this policy.
If the pkg already exists in the policy, nil is returned and
no changes are made.
@param [String,Integer] identifier the name or id of the package to add to this policy
@param position [Symbol, Integer] where to add this pkg among the list of
pkgs. Zero-based, :start and 0 are the same, as are :end and -1.
Defaults to :end
@param action [String] One of the values of PACKAGE_ACTIONS
@param feu [Boolean] Overrides the setting for the pkg itself Defaults to false
@param fut [Boolean] Overrides the setting for the pkg itself Defaults to false
@param update_autorun [Boolean] Defaults to false
@return [Array, nil] the new @packages array, nil if pkg was already in the policy
|
[
"Add",
"a",
"package",
"to",
"the",
"list",
"of",
"pkgs",
"handled",
"by",
"this",
"policy",
".",
"If",
"the",
"pkg",
"already",
"exists",
"in",
"the",
"policy",
"nil",
"is",
"returned",
"and",
"no",
"changes",
"are",
"made",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1136-L1156
|
15,829
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.remove_package
|
def remove_package(identifier)
removed = @packages.delete_if { |p| p[:id] == identifier || p[:name] == identifier }
@need_to_update = true if removed
removed
end
|
ruby
|
def remove_package(identifier)
removed = @packages.delete_if { |p| p[:id] == identifier || p[:name] == identifier }
@need_to_update = true if removed
removed
end
|
[
"def",
"remove_package",
"(",
"identifier",
")",
"removed",
"=",
"@packages",
".",
"delete_if",
"{",
"|",
"p",
"|",
"p",
"[",
":id",
"]",
"==",
"identifier",
"||",
"p",
"[",
":name",
"]",
"==",
"identifier",
"}",
"@need_to_update",
"=",
"true",
"if",
"removed",
"removed",
"end"
] |
Remove a package from this policy by name or id
@param identfier [String,Integer] the name or id of the package to remove
@return [Array, nil] the new packages array or nil if no change
|
[
"Remove",
"a",
"package",
"from",
"this",
"policy",
"by",
"name",
"or",
"id"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1164-L1168
|
15,830
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.add_script
|
def add_script(identifier, **opts)
id = validate_script_opts(identifier, opts)
return nil if @scripts.map { |s| s[:id] }.include? id
name = JSS::Script.map_all_ids_to(:name, api: @api)[id]
script_data = {
id: id,
name: name,
priority: SCRIPT_PRIORITIES[opts[:priority]],
parameter4: opts[:parameter4],
parameter5: opts[:parameter5],
parameter6: opts[:parameter6],
parameter7: opts[:parameter7],
parameter8: opts[:parameter8],
parameter9: opts[:parameter9],
parameter10: opts[:parameter10],
parameter11: opts[:parameter11]
}
@scripts.insert opts[:position], script_data
@need_to_update = true
@scripts
end
|
ruby
|
def add_script(identifier, **opts)
id = validate_script_opts(identifier, opts)
return nil if @scripts.map { |s| s[:id] }.include? id
name = JSS::Script.map_all_ids_to(:name, api: @api)[id]
script_data = {
id: id,
name: name,
priority: SCRIPT_PRIORITIES[opts[:priority]],
parameter4: opts[:parameter4],
parameter5: opts[:parameter5],
parameter6: opts[:parameter6],
parameter7: opts[:parameter7],
parameter8: opts[:parameter8],
parameter9: opts[:parameter9],
parameter10: opts[:parameter10],
parameter11: opts[:parameter11]
}
@scripts.insert opts[:position], script_data
@need_to_update = true
@scripts
end
|
[
"def",
"add_script",
"(",
"identifier",
",",
"**",
"opts",
")",
"id",
"=",
"validate_script_opts",
"(",
"identifier",
",",
"opts",
")",
"return",
"nil",
"if",
"@scripts",
".",
"map",
"{",
"|",
"s",
"|",
"s",
"[",
":id",
"]",
"}",
".",
"include?",
"id",
"name",
"=",
"JSS",
"::",
"Script",
".",
"map_all_ids_to",
"(",
":name",
",",
"api",
":",
"@api",
")",
"[",
"id",
"]",
"script_data",
"=",
"{",
"id",
":",
"id",
",",
"name",
":",
"name",
",",
"priority",
":",
"SCRIPT_PRIORITIES",
"[",
"opts",
"[",
":priority",
"]",
"]",
",",
"parameter4",
":",
"opts",
"[",
":parameter4",
"]",
",",
"parameter5",
":",
"opts",
"[",
":parameter5",
"]",
",",
"parameter6",
":",
"opts",
"[",
":parameter6",
"]",
",",
"parameter7",
":",
"opts",
"[",
":parameter7",
"]",
",",
"parameter8",
":",
"opts",
"[",
":parameter8",
"]",
",",
"parameter9",
":",
"opts",
"[",
":parameter9",
"]",
",",
"parameter10",
":",
"opts",
"[",
":parameter10",
"]",
",",
"parameter11",
":",
"opts",
"[",
":parameter11",
"]",
"}",
"@scripts",
".",
"insert",
"opts",
"[",
":position",
"]",
",",
"script_data",
"@need_to_update",
"=",
"true",
"@scripts",
"end"
] |
Add a script to the list of SCRIPT_PRIORITIESipts run by this policy.
If the script already exists in the policy, nil is returned and
no changes are made.
@param [String,Integer] identifier the name or id of the script to add to this policy
@param [Hash] opts the options for this script
@option [Symbol, Integer] position: where to add this script among the list of
scripts. Zero-based, :start and 0 are the same, as are :end and -1. Defaults to :end
@option [Symbol] priority: either :before or :after
@option [String] parameter4: the value of the 4th parameter passed to the script. this
overrides the same parameter in the script object itself.
@option [String] parameter5: the value of the 5th parameter passed to the script. this
overrides the same parameter in the script object itself.
@option [String] parameter6: the value of the 6th parameter passed to the script. this
overrides the same parameter in the script object itself.
@option [String] parameter7: the value of the 7th parameter passed to the script. this
overrides the same parameter in the script object itself.
@option [String] parameter8: the value of the 8th parameter passed to the script. this
overrides the same parameter in the script object itself.
@option [String] parameter9: the value of the 9th parameter passed to the script. this
overrides the same parameter in the script object itself.
@option [String] parameter10: the value of the 10th parameter passed to the script. this
overrides the same parameter in the script object itself.
@option [String] parameter11: the value of the 11th parameter passed to the script. this
overrides the same parameter in the script object itself.
@return [Array, nil] the new @scripts array, nil if script was already in the policy
|
[
"Add",
"a",
"script",
"to",
"the",
"list",
"of",
"SCRIPT_PRIORITIESipts",
"run",
"by",
"this",
"policy",
".",
"If",
"the",
"script",
"already",
"exists",
"in",
"the",
"policy",
"nil",
"is",
"returned",
"and",
"no",
"changes",
"are",
"made",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1221-L1246
|
15,831
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.remove_script
|
def remove_script(identifier)
removed = @scripts.delete_if { |s| s[:id] == identifier || s[:name] == identifier }
@need_to_update = true if removed
removed
end
|
ruby
|
def remove_script(identifier)
removed = @scripts.delete_if { |s| s[:id] == identifier || s[:name] == identifier }
@need_to_update = true if removed
removed
end
|
[
"def",
"remove_script",
"(",
"identifier",
")",
"removed",
"=",
"@scripts",
".",
"delete_if",
"{",
"|",
"s",
"|",
"s",
"[",
":id",
"]",
"==",
"identifier",
"||",
"s",
"[",
":name",
"]",
"==",
"identifier",
"}",
"@need_to_update",
"=",
"true",
"if",
"removed",
"removed",
"end"
] |
Remove a script from this policy by name or id
@param identfier [String,Integer] the name or id of the script to remove
@return [Array, nil] the new scripts array or nil if no change
|
[
"Remove",
"a",
"script",
"from",
"this",
"policy",
"by",
"name",
"or",
"id"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1254-L1258
|
15,832
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.run
|
def run(show_output = false)
return nil unless enabled?
output = JSS::Client.run_jamf('policy', "-id #{id}", show_output)
return nil if output.include? 'No policies were found for the ID'
$CHILD_STATUS.exitstatus.zero? ? true : false
end
|
ruby
|
def run(show_output = false)
return nil unless enabled?
output = JSS::Client.run_jamf('policy', "-id #{id}", show_output)
return nil if output.include? 'No policies were found for the ID'
$CHILD_STATUS.exitstatus.zero? ? true : false
end
|
[
"def",
"run",
"(",
"show_output",
"=",
"false",
")",
"return",
"nil",
"unless",
"enabled?",
"output",
"=",
"JSS",
"::",
"Client",
".",
"run_jamf",
"(",
"'policy'",
",",
"\"-id #{id}\"",
",",
"show_output",
")",
"return",
"nil",
"if",
"output",
".",
"include?",
"'No policies were found for the ID'",
"$CHILD_STATUS",
".",
"exitstatus",
".",
"zero?",
"?",
"true",
":",
"false",
"end"
] |
Actions
Try to execute this policy on this machine.
@param show_output[Boolean] should the stdout and stderr of the
'jamf policy' command be sent to stdout in realtime?
@return [Boolean, nil] The success of the 'jamf policy' command, or nil
if the policy couldn't be executed (out of scope, policy disabled, etc)
|
[
"Actions",
"Try",
"to",
"execute",
"this",
"policy",
"on",
"this",
"machine",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1306-L1311
|
15,833
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.flush_logs
|
def flush_logs(older_than: 0, period: :days)
raise JSS::NoSuchItemError, "Policy doesn't exist in the JSS. Use #create first." unless @in_jss
unless LOG_FLUSH_INTERVAL_INTEGERS.key?(older_than)
raise JSS::InvalidDataError, "older_than must be one of these integers: #{LOG_FLUSH_INTERVAL_INTEGERS.keys.join ', '}"
end
unless LOG_FLUSH_INTERVAL_PERIODS.key?(period)
raise JSS::InvalidDataError, "period must be one of these symbols: :#{LOG_FLUSH_INTERVAL_PERIODS.keys.join ', :'}"
end
interval = "#{LOG_FLUSH_INTERVAL_INTEGERS[older_than]}+#{LOG_FLUSH_INTERVAL_PERIODS[period]}"
@api.delete_rsrc "#{LOG_FLUSH_RSRC}/policy/id/#{@id}/interval/#{interval}"
end
|
ruby
|
def flush_logs(older_than: 0, period: :days)
raise JSS::NoSuchItemError, "Policy doesn't exist in the JSS. Use #create first." unless @in_jss
unless LOG_FLUSH_INTERVAL_INTEGERS.key?(older_than)
raise JSS::InvalidDataError, "older_than must be one of these integers: #{LOG_FLUSH_INTERVAL_INTEGERS.keys.join ', '}"
end
unless LOG_FLUSH_INTERVAL_PERIODS.key?(period)
raise JSS::InvalidDataError, "period must be one of these symbols: :#{LOG_FLUSH_INTERVAL_PERIODS.keys.join ', :'}"
end
interval = "#{LOG_FLUSH_INTERVAL_INTEGERS[older_than]}+#{LOG_FLUSH_INTERVAL_PERIODS[period]}"
@api.delete_rsrc "#{LOG_FLUSH_RSRC}/policy/id/#{@id}/interval/#{interval}"
end
|
[
"def",
"flush_logs",
"(",
"older_than",
":",
"0",
",",
"period",
":",
":days",
")",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"Policy doesn't exist in the JSS. Use #create first.\"",
"unless",
"@in_jss",
"unless",
"LOG_FLUSH_INTERVAL_INTEGERS",
".",
"key?",
"(",
"older_than",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"older_than must be one of these integers: #{LOG_FLUSH_INTERVAL_INTEGERS.keys.join ', '}\"",
"end",
"unless",
"LOG_FLUSH_INTERVAL_PERIODS",
".",
"key?",
"(",
"period",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"period must be one of these symbols: :#{LOG_FLUSH_INTERVAL_PERIODS.keys.join ', :'}\"",
"end",
"interval",
"=",
"\"#{LOG_FLUSH_INTERVAL_INTEGERS[older_than]}+#{LOG_FLUSH_INTERVAL_PERIODS[period]}\"",
"@api",
".",
"delete_rsrc",
"\"#{LOG_FLUSH_RSRC}/policy/id/#{@id}/interval/#{interval}\"",
"end"
] |
Flush all policy logs for this policy older than
some number of days, weeks, months or years.
With no parameters, flushes all logs
NOTE: Currently the API doesn't have a way to
flush only failed policies.
@param older_than[Integer] 0, 1, 2, 3, or 6
@param period[Symbol] :days, :weeks, :months, or :years
@return [void]
|
[
"Flush",
"all",
"policy",
"logs",
"for",
"this",
"policy",
"older",
"than",
"some",
"number",
"of",
"days",
"weeks",
"months",
"or",
"years",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1328-L1342
|
15,834
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.validate_package_opts
|
def validate_package_opts(identifier, opts)
opts[:position] ||= -1
opts[:action] ||= :install
opts[:feu] ||= false
opts[:fut] ||= false
opts[:update_autorun] ||= false
opts[:position] =
case opts[:position]
when :start then 0
when :end then -1
else JSS::Validate.integer(opts[:position])
end
# if the given position is past the end, set it to -1 (the end)
opts[:position] = -1 if opts[:position] > @packages.size
id = JSS::Package.valid_id identifier, api: @api
raise JSS::NoSuchItemError, "No package matches '#{identifier}'" unless id
raise JSS::InvalidDataError, "action must be one of: :#{PACKAGE_ACTIONS.keys.join ', :'}" unless \
PACKAGE_ACTIONS.include? opts[:action]
opts[:feu] = JSS::Validate.boolean opts[:feu]
opts[:fut] = JSS::Validate.boolean opts[:fut]
opts[:update_autorun] = JSS::Validate.boolean opts[:update_autorun]
id
end
|
ruby
|
def validate_package_opts(identifier, opts)
opts[:position] ||= -1
opts[:action] ||= :install
opts[:feu] ||= false
opts[:fut] ||= false
opts[:update_autorun] ||= false
opts[:position] =
case opts[:position]
when :start then 0
when :end then -1
else JSS::Validate.integer(opts[:position])
end
# if the given position is past the end, set it to -1 (the end)
opts[:position] = -1 if opts[:position] > @packages.size
id = JSS::Package.valid_id identifier, api: @api
raise JSS::NoSuchItemError, "No package matches '#{identifier}'" unless id
raise JSS::InvalidDataError, "action must be one of: :#{PACKAGE_ACTIONS.keys.join ', :'}" unless \
PACKAGE_ACTIONS.include? opts[:action]
opts[:feu] = JSS::Validate.boolean opts[:feu]
opts[:fut] = JSS::Validate.boolean opts[:fut]
opts[:update_autorun] = JSS::Validate.boolean opts[:update_autorun]
id
end
|
[
"def",
"validate_package_opts",
"(",
"identifier",
",",
"opts",
")",
"opts",
"[",
":position",
"]",
"||=",
"-",
"1",
"opts",
"[",
":action",
"]",
"||=",
":install",
"opts",
"[",
":feu",
"]",
"||=",
"false",
"opts",
"[",
":fut",
"]",
"||=",
"false",
"opts",
"[",
":update_autorun",
"]",
"||=",
"false",
"opts",
"[",
":position",
"]",
"=",
"case",
"opts",
"[",
":position",
"]",
"when",
":start",
"then",
"0",
"when",
":end",
"then",
"-",
"1",
"else",
"JSS",
"::",
"Validate",
".",
"integer",
"(",
"opts",
"[",
":position",
"]",
")",
"end",
"# if the given position is past the end, set it to -1 (the end)",
"opts",
"[",
":position",
"]",
"=",
"-",
"1",
"if",
"opts",
"[",
":position",
"]",
">",
"@packages",
".",
"size",
"id",
"=",
"JSS",
"::",
"Package",
".",
"valid_id",
"identifier",
",",
"api",
":",
"@api",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No package matches '#{identifier}'\"",
"unless",
"id",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"action must be one of: :#{PACKAGE_ACTIONS.keys.join ', :'}\"",
"unless",
"PACKAGE_ACTIONS",
".",
"include?",
"opts",
"[",
":action",
"]",
"opts",
"[",
":feu",
"]",
"=",
"JSS",
"::",
"Validate",
".",
"boolean",
"opts",
"[",
":feu",
"]",
"opts",
"[",
":fut",
"]",
"=",
"JSS",
"::",
"Validate",
".",
"boolean",
"opts",
"[",
":fut",
"]",
"opts",
"[",
":update_autorun",
"]",
"=",
"JSS",
"::",
"Validate",
".",
"boolean",
"opts",
"[",
":update_autorun",
"]",
"id",
"end"
] |
raise an error if a package being added isn't valid
@see #add_package
@return [Integer, nil] the valid id for the package
|
[
"raise",
"an",
"error",
"if",
"a",
"package",
"being",
"added",
"isn",
"t",
"valid"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1355-L1383
|
15,835
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/policy.rb
|
JSS.Policy.validate_script_opts
|
def validate_script_opts(identifier, opts)
opts[:position] ||= -1
opts[:priority] ||= :after
raise JSS::InvalidDataError, "priority must be one of: :#{SCRIPT_PRIORITIES.keys.join ', :'}" unless \
SCRIPT_PRIORITIES.include? opts[:priority]
opts[:position] =
case opts[:position]
when :start then 0
when :end then -1
else JSS::Validate.integer(opts[:position])
end
# if the given position is past the end, set it to -1 (the end)
opts[:position] = -1 if opts[:position] > @packages.size
id = JSS::Script.valid_id identifier, api: @api
raise JSS::NoSuchItemError, "No script matches '#{identifier}'" unless id
id
end
|
ruby
|
def validate_script_opts(identifier, opts)
opts[:position] ||= -1
opts[:priority] ||= :after
raise JSS::InvalidDataError, "priority must be one of: :#{SCRIPT_PRIORITIES.keys.join ', :'}" unless \
SCRIPT_PRIORITIES.include? opts[:priority]
opts[:position] =
case opts[:position]
when :start then 0
when :end then -1
else JSS::Validate.integer(opts[:position])
end
# if the given position is past the end, set it to -1 (the end)
opts[:position] = -1 if opts[:position] > @packages.size
id = JSS::Script.valid_id identifier, api: @api
raise JSS::NoSuchItemError, "No script matches '#{identifier}'" unless id
id
end
|
[
"def",
"validate_script_opts",
"(",
"identifier",
",",
"opts",
")",
"opts",
"[",
":position",
"]",
"||=",
"-",
"1",
"opts",
"[",
":priority",
"]",
"||=",
":after",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"priority must be one of: :#{SCRIPT_PRIORITIES.keys.join ', :'}\"",
"unless",
"SCRIPT_PRIORITIES",
".",
"include?",
"opts",
"[",
":priority",
"]",
"opts",
"[",
":position",
"]",
"=",
"case",
"opts",
"[",
":position",
"]",
"when",
":start",
"then",
"0",
"when",
":end",
"then",
"-",
"1",
"else",
"JSS",
"::",
"Validate",
".",
"integer",
"(",
"opts",
"[",
":position",
"]",
")",
"end",
"# if the given position is past the end, set it to -1 (the end)",
"opts",
"[",
":position",
"]",
"=",
"-",
"1",
"if",
"opts",
"[",
":position",
"]",
">",
"@packages",
".",
"size",
"id",
"=",
"JSS",
"::",
"Script",
".",
"valid_id",
"identifier",
",",
"api",
":",
"@api",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No script matches '#{identifier}'\"",
"unless",
"id",
"id",
"end"
] |
raise an error if a script being added isn't valid
@see #add_script
@return [Integer, nil] the valid id for the package
|
[
"raise",
"an",
"error",
"if",
"a",
"script",
"being",
"added",
"isn",
"t",
"valid"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/policy.rb#L1391-L1411
|
15,836
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/extension_attribute.rb
|
JSS.ExtensionAttribute.web_display=
|
def web_display=(new_val)
return nil if @web_display == new_val
raise JSS::InvalidDataError, "inventory_display must be a string, one of: #{INVENTORY_DISPLAY_CHOICES.join(', ')}" unless WEB_DISPLAY_CHOICES.include? new_val
@web_display = new_val
@need_to_update = true
end
|
ruby
|
def web_display=(new_val)
return nil if @web_display == new_val
raise JSS::InvalidDataError, "inventory_display must be a string, one of: #{INVENTORY_DISPLAY_CHOICES.join(', ')}" unless WEB_DISPLAY_CHOICES.include? new_val
@web_display = new_val
@need_to_update = true
end
|
[
"def",
"web_display",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"@web_display",
"==",
"new_val",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"inventory_display must be a string, one of: #{INVENTORY_DISPLAY_CHOICES.join(', ')}\"",
"unless",
"WEB_DISPLAY_CHOICES",
".",
"include?",
"new_val",
"@web_display",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Change the inventory_display of this EA
@param new_val[String] the new value, which must be a member of INVENTORY_DISPLAY_CHOICES
@return [void]
|
[
"Change",
"the",
"inventory_display",
"of",
"this",
"EA"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/extension_attribute.rb#L214-L219
|
15,837
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/extension_attribute.rb
|
JSS.ExtensionAttribute.input_type=
|
def input_type=(new_val)
return nil if @input_type == new_val
raise JSS::InvalidDataError, "input_type must be a string, one of: #{INPUT_TYPES.join(', ')}" unless INPUT_TYPES.include? new_val
@input_type = new_val
@popup_choices = nil if @input_type == 'Text Field'
@need_to_update = true
end
|
ruby
|
def input_type=(new_val)
return nil if @input_type == new_val
raise JSS::InvalidDataError, "input_type must be a string, one of: #{INPUT_TYPES.join(', ')}" unless INPUT_TYPES.include? new_val
@input_type = new_val
@popup_choices = nil if @input_type == 'Text Field'
@need_to_update = true
end
|
[
"def",
"input_type",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"@input_type",
"==",
"new_val",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"input_type must be a string, one of: #{INPUT_TYPES.join(', ')}\"",
"unless",
"INPUT_TYPES",
".",
"include?",
"new_val",
"@input_type",
"=",
"new_val",
"@popup_choices",
"=",
"nil",
"if",
"@input_type",
"==",
"'Text Field'",
"@need_to_update",
"=",
"true",
"end"
] |
Change the input type of this EA
@param new_val[String] the new value, which must be a member of INPUT_TYPES
@return [void]
|
[
"Change",
"the",
"input",
"type",
"of",
"this",
"EA"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/extension_attribute.rb#L227-L233
|
15,838
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/extension_attribute.rb
|
JSS.ExtensionAttribute.popup_choices=
|
def popup_choices=(new_val)
return nil if @popup_choices == new_val
raise JSS::InvalidDataError, 'popup_choices must be an Array' unless new_val.is_a?(Array)
# convert each one to a String,
# and check that it matches the @data_type
new_val.map! do |v|
v = v.to_s.strip
case @data_type
when 'Date'
raise JSS::InvalidDataError, "data_type is Date, but '#{v}' is not formatted 'YYYY-MM-DD hh:mm:ss'" unless v =~ /^\d{4}(-\d\d){2} (\d\d:){2}\d\d$/
when 'Integer'
raise JSS::InvalidDataError, "data_type is Integer, but '#{v}' is not one" unless v =~ /^\d+$/
end
v
end
self.input_type = 'Pop-up Menu'
@popup_choices = new_val
@need_to_update = true
end
|
ruby
|
def popup_choices=(new_val)
return nil if @popup_choices == new_val
raise JSS::InvalidDataError, 'popup_choices must be an Array' unless new_val.is_a?(Array)
# convert each one to a String,
# and check that it matches the @data_type
new_val.map! do |v|
v = v.to_s.strip
case @data_type
when 'Date'
raise JSS::InvalidDataError, "data_type is Date, but '#{v}' is not formatted 'YYYY-MM-DD hh:mm:ss'" unless v =~ /^\d{4}(-\d\d){2} (\d\d:){2}\d\d$/
when 'Integer'
raise JSS::InvalidDataError, "data_type is Integer, but '#{v}' is not one" unless v =~ /^\d+$/
end
v
end
self.input_type = 'Pop-up Menu'
@popup_choices = new_val
@need_to_update = true
end
|
[
"def",
"popup_choices",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"@popup_choices",
"==",
"new_val",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'popup_choices must be an Array'",
"unless",
"new_val",
".",
"is_a?",
"(",
"Array",
")",
"# convert each one to a String,",
"# and check that it matches the @data_type",
"new_val",
".",
"map!",
"do",
"|",
"v",
"|",
"v",
"=",
"v",
".",
"to_s",
".",
"strip",
"case",
"@data_type",
"when",
"'Date'",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"data_type is Date, but '#{v}' is not formatted 'YYYY-MM-DD hh:mm:ss'\"",
"unless",
"v",
"=~",
"/",
"\\d",
"\\d",
"\\d",
"\\d",
"\\d",
"\\d",
"\\d",
"/",
"when",
"'Integer'",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"data_type is Integer, but '#{v}' is not one\"",
"unless",
"v",
"=~",
"/",
"\\d",
"/",
"end",
"v",
"end",
"self",
".",
"input_type",
"=",
"'Pop-up Menu'",
"@popup_choices",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Change the Popup Choices of this EA
New value must be an Array, the items will be converted to Strings.
This automatically sets input_type to "Pop-up Menu"
Values are checked to ensure they match the @data_type
Note, Dates must be in the format "YYYY-MM-DD hh:mm:ss"
@param new_val[Array<#to_s>] the new values
@return [void]
|
[
"Change",
"the",
"Popup",
"Choices",
"of",
"this",
"EA",
"New",
"value",
"must",
"be",
"an",
"Array",
"the",
"items",
"will",
"be",
"converted",
"to",
"Strings",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/extension_attribute.rb#L247-L266
|
15,839
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/extension_attribute.rb
|
JSS.ExtensionAttribute.all_with_result
|
def all_with_result(search_type, desired_value)
raise JSS::NoSuchItemError, "EA Not In JSS! Use #create to create this #{self.class::RSRC_OBJECT_KEY}." unless @in_jss
raise JSS::InvalidDataError, 'Invalid search_type, see JSS::Criteriable::Criterion::SEARCH_TYPES' unless JSS::Criteriable::Criterion::SEARCH_TYPES.include? search_type.to_s
begin
search_class = self.class::TARGET_CLASS::SEARCH_CLASS
acs = search_class.make api: @api, name: "ruby-jss-EA-result-search-#{Time.now.to_jss_epoch}"
acs.display_fields = [@name]
crit_list = [JSS::Criteriable::Criterion.new(and_or: 'and', name: @name, search_type: search_type.to_s, value: desired_value)]
acs.criteria = JSS::Criteriable::Criteria.new crit_list
acs.create :get_results
results = []
acs.search_results.each do |i|
value = case @data_type
when 'Date' then JSS.parse_datetime i[@symbolized_name]
when 'Integer' then i[@symbolized_name].to_i
else i[@symbolized_name]
end # case
results << { id: i[:id], name: i[:name], value: value }
end
ensure
acs.delete if acs.is_a? self.class::TARGET_CLASS::SEARCH_CLASS
end
results
end
|
ruby
|
def all_with_result(search_type, desired_value)
raise JSS::NoSuchItemError, "EA Not In JSS! Use #create to create this #{self.class::RSRC_OBJECT_KEY}." unless @in_jss
raise JSS::InvalidDataError, 'Invalid search_type, see JSS::Criteriable::Criterion::SEARCH_TYPES' unless JSS::Criteriable::Criterion::SEARCH_TYPES.include? search_type.to_s
begin
search_class = self.class::TARGET_CLASS::SEARCH_CLASS
acs = search_class.make api: @api, name: "ruby-jss-EA-result-search-#{Time.now.to_jss_epoch}"
acs.display_fields = [@name]
crit_list = [JSS::Criteriable::Criterion.new(and_or: 'and', name: @name, search_type: search_type.to_s, value: desired_value)]
acs.criteria = JSS::Criteriable::Criteria.new crit_list
acs.create :get_results
results = []
acs.search_results.each do |i|
value = case @data_type
when 'Date' then JSS.parse_datetime i[@symbolized_name]
when 'Integer' then i[@symbolized_name].to_i
else i[@symbolized_name]
end # case
results << { id: i[:id], name: i[:name], value: value }
end
ensure
acs.delete if acs.is_a? self.class::TARGET_CLASS::SEARCH_CLASS
end
results
end
|
[
"def",
"all_with_result",
"(",
"search_type",
",",
"desired_value",
")",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"EA Not In JSS! Use #create to create this #{self.class::RSRC_OBJECT_KEY}.\"",
"unless",
"@in_jss",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'Invalid search_type, see JSS::Criteriable::Criterion::SEARCH_TYPES'",
"unless",
"JSS",
"::",
"Criteriable",
"::",
"Criterion",
"::",
"SEARCH_TYPES",
".",
"include?",
"search_type",
".",
"to_s",
"begin",
"search_class",
"=",
"self",
".",
"class",
"::",
"TARGET_CLASS",
"::",
"SEARCH_CLASS",
"acs",
"=",
"search_class",
".",
"make",
"api",
":",
"@api",
",",
"name",
":",
"\"ruby-jss-EA-result-search-#{Time.now.to_jss_epoch}\"",
"acs",
".",
"display_fields",
"=",
"[",
"@name",
"]",
"crit_list",
"=",
"[",
"JSS",
"::",
"Criteriable",
"::",
"Criterion",
".",
"new",
"(",
"and_or",
":",
"'and'",
",",
"name",
":",
"@name",
",",
"search_type",
":",
"search_type",
".",
"to_s",
",",
"value",
":",
"desired_value",
")",
"]",
"acs",
".",
"criteria",
"=",
"JSS",
"::",
"Criteriable",
"::",
"Criteria",
".",
"new",
"crit_list",
"acs",
".",
"create",
":get_results",
"results",
"=",
"[",
"]",
"acs",
".",
"search_results",
".",
"each",
"do",
"|",
"i",
"|",
"value",
"=",
"case",
"@data_type",
"when",
"'Date'",
"then",
"JSS",
".",
"parse_datetime",
"i",
"[",
"@symbolized_name",
"]",
"when",
"'Integer'",
"then",
"i",
"[",
"@symbolized_name",
"]",
".",
"to_i",
"else",
"i",
"[",
"@symbolized_name",
"]",
"end",
"# case",
"results",
"<<",
"{",
"id",
":",
"i",
"[",
":id",
"]",
",",
"name",
":",
"i",
"[",
":name",
"]",
",",
"value",
":",
"value",
"}",
"end",
"ensure",
"acs",
".",
"delete",
"if",
"acs",
".",
"is_a?",
"self",
".",
"class",
"::",
"TARGET_CLASS",
"::",
"SEARCH_CLASS",
"end",
"results",
"end"
] |
Get an Array of Hashes for all inventory objects
with a desired result in their latest report for this EA.
Each Hash is one inventory object (computer, mobile device, user), with these keys:
:id - the computer id
:name - the computer name
:value - the matching ext attr value for the objects latest report.
This is done by creating a temprary {AdvancedSearch} for objects with matching
values in the EA field, then getting the #search_results hash from it.
The AdvancedSearch is then deleted.
@param search_type[String] how are we comparing the stored value with the desired value.
must be a member of JSS::Criterion::SEARCH_TYPES
@param desired_value[String] the value to compare with the stored value to determine a match.
@return [Array<Hash{:id=>Integer,:name=>String,:value=>String,Integer,Time}>] the items that match the result.
|
[
"Get",
"an",
"Array",
"of",
"Hashes",
"for",
"all",
"inventory",
"objects",
"with",
"a",
"desired",
"result",
"in",
"their",
"latest",
"report",
"for",
"this",
"EA",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/extension_attribute.rb#L288-L314
|
15,840
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/extension_attribute.rb
|
JSS.ExtensionAttribute.rest_rexml
|
def rest_rexml
ea = REXML::Element.new self.class::RSRC_OBJECT_KEY.to_s
ea.add_element('name').text = @name
ea.add_element('description').text = @description
ea.add_element('data_type').text = @data_type
ea.add_element('inventory_display').text = @web_display
it = ea.add_element('input_type')
it.add_element('type').text = @input_type
if @input_type == 'Pop-up Menu'
pcs = it.add_element('popup_choices')
@popup_choices.each { |pc| pcs.add_element('choice').text = pc }
end
ea
end
|
ruby
|
def rest_rexml
ea = REXML::Element.new self.class::RSRC_OBJECT_KEY.to_s
ea.add_element('name').text = @name
ea.add_element('description').text = @description
ea.add_element('data_type').text = @data_type
ea.add_element('inventory_display').text = @web_display
it = ea.add_element('input_type')
it.add_element('type').text = @input_type
if @input_type == 'Pop-up Menu'
pcs = it.add_element('popup_choices')
@popup_choices.each { |pc| pcs.add_element('choice').text = pc }
end
ea
end
|
[
"def",
"rest_rexml",
"ea",
"=",
"REXML",
"::",
"Element",
".",
"new",
"self",
".",
"class",
"::",
"RSRC_OBJECT_KEY",
".",
"to_s",
"ea",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"@name",
"ea",
".",
"add_element",
"(",
"'description'",
")",
".",
"text",
"=",
"@description",
"ea",
".",
"add_element",
"(",
"'data_type'",
")",
".",
"text",
"=",
"@data_type",
"ea",
".",
"add_element",
"(",
"'inventory_display'",
")",
".",
"text",
"=",
"@web_display",
"it",
"=",
"ea",
".",
"add_element",
"(",
"'input_type'",
")",
"it",
".",
"add_element",
"(",
"'type'",
")",
".",
"text",
"=",
"@input_type",
"if",
"@input_type",
"==",
"'Pop-up Menu'",
"pcs",
"=",
"it",
".",
"add_element",
"(",
"'popup_choices'",
")",
"@popup_choices",
".",
"each",
"{",
"|",
"pc",
"|",
"pcs",
".",
"add_element",
"(",
"'choice'",
")",
".",
"text",
"=",
"pc",
"}",
"end",
"ea",
"end"
] |
Return a REXML object for this ext attr, with the current values.
Subclasses should augment this in their rest_xml methods
then return it .to_s, for saving or updating
|
[
"Return",
"a",
"REXML",
"object",
"for",
"this",
"ext",
"attr",
"with",
"the",
"current",
"values",
".",
"Subclasses",
"should",
"augment",
"this",
"in",
"their",
"rest_xml",
"methods",
"then",
"return",
"it",
".",
"to_s",
"for",
"saving",
"or",
"updating"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/extension_attribute.rb#L394-L408
|
15,841
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/extension_attribute/computer_extension_attribute.rb
|
JSS.ComputerExtensionAttribute.recon_display=
|
def recon_display= (new_val)
return nil if @recon_display == new_val
raise JSS::InvalidDataError, "recon_display must be a string, one of: #{RECON_DISPLAY_CHOICES.join(", ")}" unless RECON_DISPLAY_CHOICES.include? new_val
@recon_display = new_val
@need_to_update = true
end
|
ruby
|
def recon_display= (new_val)
return nil if @recon_display == new_val
raise JSS::InvalidDataError, "recon_display must be a string, one of: #{RECON_DISPLAY_CHOICES.join(", ")}" unless RECON_DISPLAY_CHOICES.include? new_val
@recon_display = new_val
@need_to_update = true
end
|
[
"def",
"recon_display",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"@recon_display",
"==",
"new_val",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"recon_display must be a string, one of: #{RECON_DISPLAY_CHOICES.join(\", \")}\"",
"unless",
"RECON_DISPLAY_CHOICES",
".",
"include?",
"new_val",
"@recon_display",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Change the recon_display of this EA
|
[
"Change",
"the",
"recon_display",
"of",
"this",
"EA"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb#L180-L185
|
15,842
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/patch_source/patch_external_source.rb
|
JSS.PatchExternalSource.validate_host_port
|
def validate_host_port(action)
raise JSS::UnsupportedError, "Cannot #{action} without first setting a host_name and port" if host_name.to_s.empty? || port.to_s.empty?
end
|
ruby
|
def validate_host_port(action)
raise JSS::UnsupportedError, "Cannot #{action} without first setting a host_name and port" if host_name.to_s.empty? || port.to_s.empty?
end
|
[
"def",
"validate_host_port",
"(",
"action",
")",
"raise",
"JSS",
"::",
"UnsupportedError",
",",
"\"Cannot #{action} without first setting a host_name and port\"",
"if",
"host_name",
".",
"to_s",
".",
"empty?",
"||",
"port",
".",
"to_s",
".",
"empty?",
"end"
] |
raise an exeption if needed when trying to do something that needs
a host and port set
@param action[String] The action that needs a host and port
@return [void]
|
[
"raise",
"an",
"exeption",
"if",
"needed",
"when",
"trying",
"to",
"do",
"something",
"that",
"needs",
"a",
"host",
"and",
"port",
"set"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_source/patch_external_source.rb#L139-L141
|
15,843
|
PixarAnimationStudios/ruby-jss
|
lib/jss/db_connection.rb
|
JSS.DBConnection.valid_server?
|
def valid_server?(server, port = DFT_PORT)
mysql = Mysql.init
mysql.options Mysql::OPT_CONNECT_TIMEOUT, 5
begin
# this connection should get an access denied error if there is
# a mysql server there. I'm assuming no one will use this username
# and pw for anything real
mysql.connect server, 'notArealUser', "definatelyNotA#{$PROCESS_ID}password", 'not_a_db', port
rescue Mysql::ServerError::AccessDeniedError
return true
rescue
return false
end
false
end
|
ruby
|
def valid_server?(server, port = DFT_PORT)
mysql = Mysql.init
mysql.options Mysql::OPT_CONNECT_TIMEOUT, 5
begin
# this connection should get an access denied error if there is
# a mysql server there. I'm assuming no one will use this username
# and pw for anything real
mysql.connect server, 'notArealUser', "definatelyNotA#{$PROCESS_ID}password", 'not_a_db', port
rescue Mysql::ServerError::AccessDeniedError
return true
rescue
return false
end
false
end
|
[
"def",
"valid_server?",
"(",
"server",
",",
"port",
"=",
"DFT_PORT",
")",
"mysql",
"=",
"Mysql",
".",
"init",
"mysql",
".",
"options",
"Mysql",
"::",
"OPT_CONNECT_TIMEOUT",
",",
"5",
"begin",
"# this connection should get an access denied error if there is",
"# a mysql server there. I'm assuming no one will use this username",
"# and pw for anything real",
"mysql",
".",
"connect",
"server",
",",
"'notArealUser'",
",",
"\"definatelyNotA#{$PROCESS_ID}password\"",
",",
"'not_a_db'",
",",
"port",
"rescue",
"Mysql",
"::",
"ServerError",
"::",
"AccessDeniedError",
"return",
"true",
"rescue",
"return",
"false",
"end",
"false",
"end"
] |
disconnect
Test that a given hostname is a MySQL server
@param server[String] The hostname to test
@return [Boolean] does the server host a MySQL server?
|
[
"disconnect",
"Test",
"that",
"a",
"given",
"hostname",
"is",
"a",
"MySQL",
"server"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/db_connection.rb#L240-L256
|
15,844
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.add_self_service_category
|
def add_self_service_category(new_cat, display_in: true, feature_in: false)
new_cat = JSS::Category.map_all_ids_to(:name, api: @api)[new_cat] if new_cat.is_a? Integer
feature_in = false if display_in == false
raise JSS::NoSuchItemError, "No category '#{new_cat}' in the JSS" unless JSS::Category.all_names(:refresh, api: @api).include? new_cat
raise JSS::InvalidDataError, 'display_in must be true or false' unless display_in.jss_boolean?
raise JSS::InvalidDataError, 'feature_in must be true or false' unless feature_in.jss_boolean?
new_data = { name: new_cat }
new_data[:display_in] = display_in if @self_service_data_config[:can_display_in_categories]
new_data[:feature_in] = feature_in if @self_service_data_config[:can_feature_in_categories]
# see if this category is already among our categories.
idx = @self_service_categories.index { |c| c[:name] == new_cat }
if idx
@self_service_categories[idx] = new_data
else
@self_service_categories << new_data
end
@need_to_update = true
end
|
ruby
|
def add_self_service_category(new_cat, display_in: true, feature_in: false)
new_cat = JSS::Category.map_all_ids_to(:name, api: @api)[new_cat] if new_cat.is_a? Integer
feature_in = false if display_in == false
raise JSS::NoSuchItemError, "No category '#{new_cat}' in the JSS" unless JSS::Category.all_names(:refresh, api: @api).include? new_cat
raise JSS::InvalidDataError, 'display_in must be true or false' unless display_in.jss_boolean?
raise JSS::InvalidDataError, 'feature_in must be true or false' unless feature_in.jss_boolean?
new_data = { name: new_cat }
new_data[:display_in] = display_in if @self_service_data_config[:can_display_in_categories]
new_data[:feature_in] = feature_in if @self_service_data_config[:can_feature_in_categories]
# see if this category is already among our categories.
idx = @self_service_categories.index { |c| c[:name] == new_cat }
if idx
@self_service_categories[idx] = new_data
else
@self_service_categories << new_data
end
@need_to_update = true
end
|
[
"def",
"add_self_service_category",
"(",
"new_cat",
",",
"display_in",
":",
"true",
",",
"feature_in",
":",
"false",
")",
"new_cat",
"=",
"JSS",
"::",
"Category",
".",
"map_all_ids_to",
"(",
":name",
",",
"api",
":",
"@api",
")",
"[",
"new_cat",
"]",
"if",
"new_cat",
".",
"is_a?",
"Integer",
"feature_in",
"=",
"false",
"if",
"display_in",
"==",
"false",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No category '#{new_cat}' in the JSS\"",
"unless",
"JSS",
"::",
"Category",
".",
"all_names",
"(",
":refresh",
",",
"api",
":",
"@api",
")",
".",
"include?",
"new_cat",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'display_in must be true or false'",
"unless",
"display_in",
".",
"jss_boolean?",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'feature_in must be true or false'",
"unless",
"feature_in",
".",
"jss_boolean?",
"new_data",
"=",
"{",
"name",
":",
"new_cat",
"}",
"new_data",
"[",
":display_in",
"]",
"=",
"display_in",
"if",
"@self_service_data_config",
"[",
":can_display_in_categories",
"]",
"new_data",
"[",
":feature_in",
"]",
"=",
"feature_in",
"if",
"@self_service_data_config",
"[",
":can_feature_in_categories",
"]",
"# see if this category is already among our categories.",
"idx",
"=",
"@self_service_categories",
".",
"index",
"{",
"|",
"c",
"|",
"c",
"[",
":name",
"]",
"==",
"new_cat",
"}",
"if",
"idx",
"@self_service_categories",
"[",
"idx",
"]",
"=",
"new_data",
"else",
"@self_service_categories",
"<<",
"new_data",
"end",
"@need_to_update",
"=",
"true",
"end"
] |
Add or change one of the categories for this item in self service
@param new_cat[String, Integer] the name or id of a category where this
object should appear in SelfSvc
@param display_in[Boolean] should this item appear in the SelfSvc page for
the category? Only meaningful in applicable classes
@param feature_in[Boolean] should this item be featured in the SelfSvc page
for the category? Only meaningful in applicable classes.
NOTE: this will always be false if display_in is false.
@return [void]
|
[
"Add",
"or",
"change",
"one",
"of",
"the",
"categories",
"for",
"this",
"item",
"in",
"self",
"service"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L431-L454
|
15,845
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.self_service_user_removable=
|
def self_service_user_removable=(new_val, pw = @self_service_removal_password)
new_val, pw = *new_val if new_val.is_a? Array
pw = nil unless new_val == :with_auth
return if new_val == self_service_user_removable && pw == self_service_removal_password
validate_user_removable new_val
@self_service_user_removable = new_val
@self_service_removal_password = pw
@need_to_update = true
end
|
ruby
|
def self_service_user_removable=(new_val, pw = @self_service_removal_password)
new_val, pw = *new_val if new_val.is_a? Array
pw = nil unless new_val == :with_auth
return if new_val == self_service_user_removable && pw == self_service_removal_password
validate_user_removable new_val
@self_service_user_removable = new_val
@self_service_removal_password = pw
@need_to_update = true
end
|
[
"def",
"self_service_user_removable",
"=",
"(",
"new_val",
",",
"pw",
"=",
"@self_service_removal_password",
")",
"new_val",
",",
"pw",
"=",
"new_val",
"if",
"new_val",
".",
"is_a?",
"Array",
"pw",
"=",
"nil",
"unless",
"new_val",
"==",
":with_auth",
"return",
"if",
"new_val",
"==",
"self_service_user_removable",
"&&",
"pw",
"==",
"self_service_removal_password",
"validate_user_removable",
"new_val",
"@self_service_user_removable",
"=",
"new_val",
"@self_service_removal_password",
"=",
"pw",
"@need_to_update",
"=",
"true",
"end"
] |
Set the value for user-removability of profiles, optionally
providing a password for removal, on iOS targets.
@param new_val[Symbol] One of the keys of PROFILE_REMOVAL_BY_USER,
:always, :never, or :with_auth
@param pw[String] A new password to use if removable :with_auth
@return [void]
|
[
"Set",
"the",
"value",
"for",
"user",
"-",
"removability",
"of",
"profiles",
"optionally",
"providing",
"a",
"password",
"for",
"removal",
"on",
"iOS",
"targets",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L479-L490
|
15,846
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.self_service_notification_type=
|
def self_service_notification_type=(type)
validate_notifications_supported
# HACK: Until jamf fixes bugs, you can only set notifications
# :off or :ssvc_only. If you want :ssvc_and_nctr, you must
# check the checkbox in the web-UI.
if @self_service_data_config[:notifications_supported] == :ssvc_only && type != :ssvc_only
raise "JAMF BUG: Until Jamf fixes API bugs in #{self.class}, you can only set Self Service notifications to :ssvc_only. Use the WebUI to activate Notification Center notifications"
end
raise JSS::InvalidDataError, "type must be one of: :#{NOTIFICATION_TYPES.keys.join ', :'}" unless NOTIFICATION_TYPES.key? type
@self_service_notification_type = type
@need_to_update = true
end
|
ruby
|
def self_service_notification_type=(type)
validate_notifications_supported
# HACK: Until jamf fixes bugs, you can only set notifications
# :off or :ssvc_only. If you want :ssvc_and_nctr, you must
# check the checkbox in the web-UI.
if @self_service_data_config[:notifications_supported] == :ssvc_only && type != :ssvc_only
raise "JAMF BUG: Until Jamf fixes API bugs in #{self.class}, you can only set Self Service notifications to :ssvc_only. Use the WebUI to activate Notification Center notifications"
end
raise JSS::InvalidDataError, "type must be one of: :#{NOTIFICATION_TYPES.keys.join ', :'}" unless NOTIFICATION_TYPES.key? type
@self_service_notification_type = type
@need_to_update = true
end
|
[
"def",
"self_service_notification_type",
"=",
"(",
"type",
")",
"validate_notifications_supported",
"# HACK: Until jamf fixes bugs, you can only set notifications",
"# :off or :ssvc_only. If you want :ssvc_and_nctr, you must",
"# check the checkbox in the web-UI.",
"if",
"@self_service_data_config",
"[",
":notifications_supported",
"]",
"==",
":ssvc_only",
"&&",
"type",
"!=",
":ssvc_only",
"raise",
"\"JAMF BUG: Until Jamf fixes API bugs in #{self.class}, you can only set Self Service notifications to :ssvc_only. Use the WebUI to activate Notification Center notifications\"",
"end",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"type must be one of: :#{NOTIFICATION_TYPES.keys.join ', :'}\"",
"unless",
"NOTIFICATION_TYPES",
".",
"key?",
"type",
"@self_service_notification_type",
"=",
"type",
"@need_to_update",
"=",
"true",
"end"
] |
How should self service notifications be displayed
@param type[Symbol] A key from SelfServable::NOTIFICATION_TYPES
@return [void]
|
[
"How",
"should",
"self",
"service",
"notifications",
"be",
"displayed"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L512-L526
|
15,847
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.self_service_reminder_frequency=
|
def self_service_reminder_frequency=(days)
return if days == self_service_reminder_frequency
validate_notification_reminders_supported
JSS::Validate.integer days
@self_service_reminder_frequency = days
@need_to_update = true
end
|
ruby
|
def self_service_reminder_frequency=(days)
return if days == self_service_reminder_frequency
validate_notification_reminders_supported
JSS::Validate.integer days
@self_service_reminder_frequency = days
@need_to_update = true
end
|
[
"def",
"self_service_reminder_frequency",
"=",
"(",
"days",
")",
"return",
"if",
"days",
"==",
"self_service_reminder_frequency",
"validate_notification_reminders_supported",
"JSS",
"::",
"Validate",
".",
"integer",
"days",
"@self_service_reminder_frequency",
"=",
"days",
"@need_to_update",
"=",
"true",
"end"
] |
set reminder notification frequency
@param new_val[Integer] How many days between reminder notifications?
@return [void]
|
[
"set",
"reminder",
"notification",
"frequency"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L572-L578
|
15,848
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.icon=
|
def icon=(new_icon)
if new_icon.is_a? Integer
return if @icon && new_icon == @icon.id
validate_icon new_icon
@new_icon_id = new_icon
@need_to_update = true
else
unless uploadable? && defined?(self.class::UPLOAD_TYPES) && self.class::UPLOAD_TYPES.key?(:icon)
raise JSS::UnsupportedError, "Class #{self.class} does not support icon uploads."
end
new_icon = Pathname.new new_icon
upload(:icon, new_icon)
refresh_icon
end # new_icon.is_a? Integer
new_icon
end
|
ruby
|
def icon=(new_icon)
if new_icon.is_a? Integer
return if @icon && new_icon == @icon.id
validate_icon new_icon
@new_icon_id = new_icon
@need_to_update = true
else
unless uploadable? && defined?(self.class::UPLOAD_TYPES) && self.class::UPLOAD_TYPES.key?(:icon)
raise JSS::UnsupportedError, "Class #{self.class} does not support icon uploads."
end
new_icon = Pathname.new new_icon
upload(:icon, new_icon)
refresh_icon
end # new_icon.is_a? Integer
new_icon
end
|
[
"def",
"icon",
"=",
"(",
"new_icon",
")",
"if",
"new_icon",
".",
"is_a?",
"Integer",
"return",
"if",
"@icon",
"&&",
"new_icon",
"==",
"@icon",
".",
"id",
"validate_icon",
"new_icon",
"@new_icon_id",
"=",
"new_icon",
"@need_to_update",
"=",
"true",
"else",
"unless",
"uploadable?",
"&&",
"defined?",
"(",
"self",
".",
"class",
"::",
"UPLOAD_TYPES",
")",
"&&",
"self",
".",
"class",
"::",
"UPLOAD_TYPES",
".",
"key?",
"(",
":icon",
")",
"raise",
"JSS",
"::",
"UnsupportedError",
",",
"\"Class #{self.class} does not support icon uploads.\"",
"end",
"new_icon",
"=",
"Pathname",
".",
"new",
"new_icon",
"upload",
"(",
":icon",
",",
"new_icon",
")",
"refresh_icon",
"end",
"# new_icon.is_a? Integer",
"new_icon",
"end"
] |
Set a new Self Service icon for this object.
Since JSS::Icon objects are read-only,
the icon can only be changed by supplying the id number
of an icon already existing in the JSS, or a path to
a local file, which will be uploaded to the JSS and added
to this instance. Uploads
take effect immediately, but if an integer is supplied, the change
must be sent to the JSS via {#update} or {#create}
@param new_icon[Integer, String, Pathname] The id or path to the new icon.
@return [false, Integer, Pathname] false means no change was made.
|
[
"Set",
"a",
"new",
"Self",
"Service",
"icon",
"for",
"this",
"object",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L594-L609
|
15,849
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.parse_self_service_notifications
|
def parse_self_service_notifications(ss_data)
return unless @self_service_data_config[:notifications_supported]
# oldstyle/broken, we need the XML to know if notifications are turned on
if @self_service_data_config[:notifications_supported] == :ssvc_only && @in_jss
ssrsrc = "#{rest_rsrc}/subset/selfservice"
raw_xml = api.get_rsrc(ssrsrc, :xml)
@self_service_notifications_enabled = raw_xml.include? '<notification>true</notification>'
@self_service_notification_type = NOTIFICATION_TYPES.invert[ss_data[:notification]]
@self_service_notification_subject = ss_data[:notification_subject]
@self_service_notification_message = ss_data[:notification_message]
return
end
# newstyle, 'notifications' subset
notif_data = ss_data[:notifications]
notif_data ||= {}
@self_service_notifications_enabled = notif_data[:notification_enabled]
@self_service_notification_type = NOTIFICATION_TYPES.invert[notif_data[:notification_type]]
@self_service_notification_type ||= DFT_NOTIFICATION_TYPE
@self_service_notification_subject = notif_data[:notification_subject]
@self_service_notification_message = notif_data[:notification_message]
reminders = notif_data[:reminders]
reminders ||= {}
@self_service_reminders_enabled = reminders[:notification_reminders_enabled]
@self_service_reminder_frequency = reminders[:notification_reminder_frequency]
end
|
ruby
|
def parse_self_service_notifications(ss_data)
return unless @self_service_data_config[:notifications_supported]
# oldstyle/broken, we need the XML to know if notifications are turned on
if @self_service_data_config[:notifications_supported] == :ssvc_only && @in_jss
ssrsrc = "#{rest_rsrc}/subset/selfservice"
raw_xml = api.get_rsrc(ssrsrc, :xml)
@self_service_notifications_enabled = raw_xml.include? '<notification>true</notification>'
@self_service_notification_type = NOTIFICATION_TYPES.invert[ss_data[:notification]]
@self_service_notification_subject = ss_data[:notification_subject]
@self_service_notification_message = ss_data[:notification_message]
return
end
# newstyle, 'notifications' subset
notif_data = ss_data[:notifications]
notif_data ||= {}
@self_service_notifications_enabled = notif_data[:notification_enabled]
@self_service_notification_type = NOTIFICATION_TYPES.invert[notif_data[:notification_type]]
@self_service_notification_type ||= DFT_NOTIFICATION_TYPE
@self_service_notification_subject = notif_data[:notification_subject]
@self_service_notification_message = notif_data[:notification_message]
reminders = notif_data[:reminders]
reminders ||= {}
@self_service_reminders_enabled = reminders[:notification_reminders_enabled]
@self_service_reminder_frequency = reminders[:notification_reminder_frequency]
end
|
[
"def",
"parse_self_service_notifications",
"(",
"ss_data",
")",
"return",
"unless",
"@self_service_data_config",
"[",
":notifications_supported",
"]",
"# oldstyle/broken, we need the XML to know if notifications are turned on",
"if",
"@self_service_data_config",
"[",
":notifications_supported",
"]",
"==",
":ssvc_only",
"&&",
"@in_jss",
"ssrsrc",
"=",
"\"#{rest_rsrc}/subset/selfservice\"",
"raw_xml",
"=",
"api",
".",
"get_rsrc",
"(",
"ssrsrc",
",",
":xml",
")",
"@self_service_notifications_enabled",
"=",
"raw_xml",
".",
"include?",
"'<notification>true</notification>'",
"@self_service_notification_type",
"=",
"NOTIFICATION_TYPES",
".",
"invert",
"[",
"ss_data",
"[",
":notification",
"]",
"]",
"@self_service_notification_subject",
"=",
"ss_data",
"[",
":notification_subject",
"]",
"@self_service_notification_message",
"=",
"ss_data",
"[",
":notification_message",
"]",
"return",
"end",
"# newstyle, 'notifications' subset",
"notif_data",
"=",
"ss_data",
"[",
":notifications",
"]",
"notif_data",
"||=",
"{",
"}",
"@self_service_notifications_enabled",
"=",
"notif_data",
"[",
":notification_enabled",
"]",
"@self_service_notification_type",
"=",
"NOTIFICATION_TYPES",
".",
"invert",
"[",
"notif_data",
"[",
":notification_type",
"]",
"]",
"@self_service_notification_type",
"||=",
"DFT_NOTIFICATION_TYPE",
"@self_service_notification_subject",
"=",
"notif_data",
"[",
":notification_subject",
"]",
"@self_service_notification_message",
"=",
"notif_data",
"[",
":notification_message",
"]",
"reminders",
"=",
"notif_data",
"[",
":reminders",
"]",
"reminders",
"||=",
"{",
"}",
"@self_service_reminders_enabled",
"=",
"reminders",
"[",
":notification_reminders_enabled",
"]",
"@self_service_reminder_frequency",
"=",
"reminders",
"[",
":notification_reminder_frequency",
"]",
"end"
] |
parse incoming ssvc notification settings
|
[
"parse",
"incoming",
"ssvc",
"notification",
"settings"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L760-L788
|
15,850
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.add_self_service_xml
|
def add_self_service_xml(xdoc)
doc_root = xdoc.root
# whether or not we're in self service is usually not in the
# ssvc subset...
add_in_self_service_xml doc_root
subset_key = @self_service_data_config[:self_service_subset] ? @self_service_data_config[:self_service_subset] : :self_service
ssvc = doc_root.add_element subset_key.to_s
ssvc.add_element('self_service_description').text = @self_service_description if @self_service_description
ssvc.add_element('feature_on_main_page').text = @self_service_feature_on_main_page
if @new_icon_id
icon = ssvc.add_element('self_service_icon')
icon.add_element('id').text = @new_icon_id
end
add_self_service_category_xml ssvc
add_self_service_profile_xml ssvc, doc_root
add_self_service_macos_xml ssvc
add_self_service_notification_xml ssvc
end
|
ruby
|
def add_self_service_xml(xdoc)
doc_root = xdoc.root
# whether or not we're in self service is usually not in the
# ssvc subset...
add_in_self_service_xml doc_root
subset_key = @self_service_data_config[:self_service_subset] ? @self_service_data_config[:self_service_subset] : :self_service
ssvc = doc_root.add_element subset_key.to_s
ssvc.add_element('self_service_description').text = @self_service_description if @self_service_description
ssvc.add_element('feature_on_main_page').text = @self_service_feature_on_main_page
if @new_icon_id
icon = ssvc.add_element('self_service_icon')
icon.add_element('id').text = @new_icon_id
end
add_self_service_category_xml ssvc
add_self_service_profile_xml ssvc, doc_root
add_self_service_macos_xml ssvc
add_self_service_notification_xml ssvc
end
|
[
"def",
"add_self_service_xml",
"(",
"xdoc",
")",
"doc_root",
"=",
"xdoc",
".",
"root",
"# whether or not we're in self service is usually not in the",
"# ssvc subset...",
"add_in_self_service_xml",
"doc_root",
"subset_key",
"=",
"@self_service_data_config",
"[",
":self_service_subset",
"]",
"?",
"@self_service_data_config",
"[",
":self_service_subset",
"]",
":",
":self_service",
"ssvc",
"=",
"doc_root",
".",
"add_element",
"subset_key",
".",
"to_s",
"ssvc",
".",
"add_element",
"(",
"'self_service_description'",
")",
".",
"text",
"=",
"@self_service_description",
"if",
"@self_service_description",
"ssvc",
".",
"add_element",
"(",
"'feature_on_main_page'",
")",
".",
"text",
"=",
"@self_service_feature_on_main_page",
"if",
"@new_icon_id",
"icon",
"=",
"ssvc",
".",
"add_element",
"(",
"'self_service_icon'",
")",
"icon",
".",
"add_element",
"(",
"'id'",
")",
".",
"text",
"=",
"@new_icon_id",
"end",
"add_self_service_category_xml",
"ssvc",
"add_self_service_profile_xml",
"ssvc",
",",
"doc_root",
"add_self_service_macos_xml",
"ssvc",
"add_self_service_notification_xml",
"ssvc",
"end"
] |
refresh icon
Add approriate XML for self service data to the XML document for this
item.
@param xdoc[REXML::Document] The XML Document to which we're adding Self
Service data
@return [void]
|
[
"refresh",
"icon",
"Add",
"approriate",
"XML",
"for",
"self",
"service",
"data",
"to",
"the",
"XML",
"document",
"for",
"this",
"item",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L814-L840
|
15,851
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.add_in_self_service_xml
|
def add_in_self_service_xml(doc_root)
return unless @self_service_data_config[:in_self_service_data_path]
in_ss_section, in_ss_elem = @self_service_data_config[:in_self_service_data_path]
in_ss_value = @in_self_service ? @self_service_data_config[:in_self_service] : @self_service_data_config[:not_in_self_service]
in_ss_section_xml = doc_root.elements[in_ss_section.to_s]
in_ss_section_xml ||= doc_root.add_element(in_ss_section.to_s)
in_ss_section_xml.add_element(in_ss_elem.to_s).text = in_ss_value.to_s
end
|
ruby
|
def add_in_self_service_xml(doc_root)
return unless @self_service_data_config[:in_self_service_data_path]
in_ss_section, in_ss_elem = @self_service_data_config[:in_self_service_data_path]
in_ss_value = @in_self_service ? @self_service_data_config[:in_self_service] : @self_service_data_config[:not_in_self_service]
in_ss_section_xml = doc_root.elements[in_ss_section.to_s]
in_ss_section_xml ||= doc_root.add_element(in_ss_section.to_s)
in_ss_section_xml.add_element(in_ss_elem.to_s).text = in_ss_value.to_s
end
|
[
"def",
"add_in_self_service_xml",
"(",
"doc_root",
")",
"return",
"unless",
"@self_service_data_config",
"[",
":in_self_service_data_path",
"]",
"in_ss_section",
",",
"in_ss_elem",
"=",
"@self_service_data_config",
"[",
":in_self_service_data_path",
"]",
"in_ss_value",
"=",
"@in_self_service",
"?",
"@self_service_data_config",
"[",
":in_self_service",
"]",
":",
"@self_service_data_config",
"[",
":not_in_self_service",
"]",
"in_ss_section_xml",
"=",
"doc_root",
".",
"elements",
"[",
"in_ss_section",
".",
"to_s",
"]",
"in_ss_section_xml",
"||=",
"doc_root",
".",
"add_element",
"(",
"in_ss_section",
".",
"to_s",
")",
"in_ss_section_xml",
".",
"add_element",
"(",
"in_ss_elem",
".",
"to_s",
")",
".",
"text",
"=",
"in_ss_value",
".",
"to_s",
"end"
] |
add_self_service_xml
add the correct XML indicating whether or not we're even in SSvc
|
[
"add_self_service_xml",
"add",
"the",
"correct",
"XML",
"indicating",
"whether",
"or",
"not",
"we",
"re",
"even",
"in",
"SSvc"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L843-L853
|
15,852
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.add_self_service_profile_xml
|
def add_self_service_profile_xml(ssvc, doc_root)
return unless self_service_payload == :profile
if self_service_targets.include? :ios
sec = ssvc.add_element('security')
sec.add_element('removal_disallowed').text = PROFILE_REMOVAL_BY_USER[@self_service_user_removable]
sec.add_element('password').text = @self_service_removal_password.to_s
return
end
gen = doc_root.elements['general']
gen.add_element('user_removable').text = (@self_service_user_removable == :always).to_s
end
|
ruby
|
def add_self_service_profile_xml(ssvc, doc_root)
return unless self_service_payload == :profile
if self_service_targets.include? :ios
sec = ssvc.add_element('security')
sec.add_element('removal_disallowed').text = PROFILE_REMOVAL_BY_USER[@self_service_user_removable]
sec.add_element('password').text = @self_service_removal_password.to_s
return
end
gen = doc_root.elements['general']
gen.add_element('user_removable').text = (@self_service_user_removable == :always).to_s
end
|
[
"def",
"add_self_service_profile_xml",
"(",
"ssvc",
",",
"doc_root",
")",
"return",
"unless",
"self_service_payload",
"==",
":profile",
"if",
"self_service_targets",
".",
"include?",
":ios",
"sec",
"=",
"ssvc",
".",
"add_element",
"(",
"'security'",
")",
"sec",
".",
"add_element",
"(",
"'removal_disallowed'",
")",
".",
"text",
"=",
"PROFILE_REMOVAL_BY_USER",
"[",
"@self_service_user_removable",
"]",
"sec",
".",
"add_element",
"(",
"'password'",
")",
".",
"text",
"=",
"@self_service_removal_password",
".",
"to_s",
"return",
"end",
"gen",
"=",
"doc_root",
".",
"elements",
"[",
"'general'",
"]",
"gen",
".",
"add_element",
"(",
"'user_removable'",
")",
".",
"text",
"=",
"(",
"@self_service_user_removable",
"==",
":always",
")",
".",
"to_s",
"end"
] |
add the xml specific to profiles
|
[
"add",
"the",
"xml",
"specific",
"to",
"profiles"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L856-L866
|
15,853
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.add_self_service_category_xml
|
def add_self_service_category_xml(ssvc)
cats = ssvc.add_element('self_service_categories')
return if self_service_categories.empty?
self_service_categories.each do |cat|
catelem = cats.add_element('category')
catelem.add_element('name').text = cat[:name]
catelem.add_element('display_in').text = cat[:display_in] if @self_service_data_config[:can_display_in_categories]
catelem.add_element('feature_in').text = cat[:feature_in] if @self_service_data_config[:can_feature_in_categories]
end
end
|
ruby
|
def add_self_service_category_xml(ssvc)
cats = ssvc.add_element('self_service_categories')
return if self_service_categories.empty?
self_service_categories.each do |cat|
catelem = cats.add_element('category')
catelem.add_element('name').text = cat[:name]
catelem.add_element('display_in').text = cat[:display_in] if @self_service_data_config[:can_display_in_categories]
catelem.add_element('feature_in').text = cat[:feature_in] if @self_service_data_config[:can_feature_in_categories]
end
end
|
[
"def",
"add_self_service_category_xml",
"(",
"ssvc",
")",
"cats",
"=",
"ssvc",
".",
"add_element",
"(",
"'self_service_categories'",
")",
"return",
"if",
"self_service_categories",
".",
"empty?",
"self_service_categories",
".",
"each",
"do",
"|",
"cat",
"|",
"catelem",
"=",
"cats",
".",
"add_element",
"(",
"'category'",
")",
"catelem",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"cat",
"[",
":name",
"]",
"catelem",
".",
"add_element",
"(",
"'display_in'",
")",
".",
"text",
"=",
"cat",
"[",
":display_in",
"]",
"if",
"@self_service_data_config",
"[",
":can_display_in_categories",
"]",
"catelem",
".",
"add_element",
"(",
"'feature_in'",
")",
".",
"text",
"=",
"cat",
"[",
":feature_in",
"]",
"if",
"@self_service_data_config",
"[",
":can_feature_in_categories",
"]",
"end",
"end"
] |
add the xml for self-service categories
|
[
"add",
"the",
"xml",
"for",
"self",
"-",
"service",
"categories"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L869-L878
|
15,854
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.add_self_service_macos_xml
|
def add_self_service_macos_xml(ssvc)
return unless self_service_targets.include? :macos
ssvc.add_element('self_service_display_name').text = self_service_display_name if self_service_display_name
ssvc.add_element('install_button_text').text = self_service_install_button_text if self_service_install_button_text
ssvc.add_element('reinstall_button_text').text = self_service_reinstall_button_text if self_service_reinstall_button_text
ssvc.add_element('force_users_to_view_description').text = self_service_force_users_to_view_description.to_s
end
|
ruby
|
def add_self_service_macos_xml(ssvc)
return unless self_service_targets.include? :macos
ssvc.add_element('self_service_display_name').text = self_service_display_name if self_service_display_name
ssvc.add_element('install_button_text').text = self_service_install_button_text if self_service_install_button_text
ssvc.add_element('reinstall_button_text').text = self_service_reinstall_button_text if self_service_reinstall_button_text
ssvc.add_element('force_users_to_view_description').text = self_service_force_users_to_view_description.to_s
end
|
[
"def",
"add_self_service_macos_xml",
"(",
"ssvc",
")",
"return",
"unless",
"self_service_targets",
".",
"include?",
":macos",
"ssvc",
".",
"add_element",
"(",
"'self_service_display_name'",
")",
".",
"text",
"=",
"self_service_display_name",
"if",
"self_service_display_name",
"ssvc",
".",
"add_element",
"(",
"'install_button_text'",
")",
".",
"text",
"=",
"self_service_install_button_text",
"if",
"self_service_install_button_text",
"ssvc",
".",
"add_element",
"(",
"'reinstall_button_text'",
")",
".",
"text",
"=",
"self_service_reinstall_button_text",
"if",
"self_service_reinstall_button_text",
"ssvc",
".",
"add_element",
"(",
"'force_users_to_view_description'",
")",
".",
"text",
"=",
"self_service_force_users_to_view_description",
".",
"to_s",
"end"
] |
set macOS settings in ssvc xml
|
[
"set",
"macOS",
"settings",
"in",
"ssvc",
"xml"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L881-L887
|
15,855
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.add_self_service_notification_xml
|
def add_self_service_notification_xml(ssvc)
return unless @self_service_data_config[:notifications_supported]
# oldstyle/broken, only sscv notifs
if @self_service_data_config[:notifications_supported] == :ssvc_only
ssvc.add_element('notification').text = self_service_notifications_enabled.to_s
ssvc.add_element('notification_subject').text = self_service_notification_subject if self_service_notification_subject
ssvc.add_element('notification_message').text = self_service_notification_message if self_service_notification_message
return
end
# newstyle, 'notifications' subset
notif = ssvc.add_element('notifications')
notif.add_element('notifications_enabled').text = self_service_notifications_enabled.to_s
notif.add_element('notification_type').text = NOTIFICATION_TYPES[self_service_notification_type] if self_service_notification_type
notif.add_element('notification_subject').text = self_service_notification_subject if self_service_notification_subject
notif.add_element('notification_message').text = self_service_notification_message if self_service_notification_message
return unless @self_service_data_config[:notification_reminders]
reminds = notif.add_element('reminders')
reminds.add_element('notification_reminders_enabled').text = self_service_reminders_enabled.to_s
reminds.add_element('notification_reminder_frequency').text = self_service_reminder_frequency.to_s if self_service_reminder_frequency
end
|
ruby
|
def add_self_service_notification_xml(ssvc)
return unless @self_service_data_config[:notifications_supported]
# oldstyle/broken, only sscv notifs
if @self_service_data_config[:notifications_supported] == :ssvc_only
ssvc.add_element('notification').text = self_service_notifications_enabled.to_s
ssvc.add_element('notification_subject').text = self_service_notification_subject if self_service_notification_subject
ssvc.add_element('notification_message').text = self_service_notification_message if self_service_notification_message
return
end
# newstyle, 'notifications' subset
notif = ssvc.add_element('notifications')
notif.add_element('notifications_enabled').text = self_service_notifications_enabled.to_s
notif.add_element('notification_type').text = NOTIFICATION_TYPES[self_service_notification_type] if self_service_notification_type
notif.add_element('notification_subject').text = self_service_notification_subject if self_service_notification_subject
notif.add_element('notification_message').text = self_service_notification_message if self_service_notification_message
return unless @self_service_data_config[:notification_reminders]
reminds = notif.add_element('reminders')
reminds.add_element('notification_reminders_enabled').text = self_service_reminders_enabled.to_s
reminds.add_element('notification_reminder_frequency').text = self_service_reminder_frequency.to_s if self_service_reminder_frequency
end
|
[
"def",
"add_self_service_notification_xml",
"(",
"ssvc",
")",
"return",
"unless",
"@self_service_data_config",
"[",
":notifications_supported",
"]",
"# oldstyle/broken, only sscv notifs",
"if",
"@self_service_data_config",
"[",
":notifications_supported",
"]",
"==",
":ssvc_only",
"ssvc",
".",
"add_element",
"(",
"'notification'",
")",
".",
"text",
"=",
"self_service_notifications_enabled",
".",
"to_s",
"ssvc",
".",
"add_element",
"(",
"'notification_subject'",
")",
".",
"text",
"=",
"self_service_notification_subject",
"if",
"self_service_notification_subject",
"ssvc",
".",
"add_element",
"(",
"'notification_message'",
")",
".",
"text",
"=",
"self_service_notification_message",
"if",
"self_service_notification_message",
"return",
"end",
"# newstyle, 'notifications' subset",
"notif",
"=",
"ssvc",
".",
"add_element",
"(",
"'notifications'",
")",
"notif",
".",
"add_element",
"(",
"'notifications_enabled'",
")",
".",
"text",
"=",
"self_service_notifications_enabled",
".",
"to_s",
"notif",
".",
"add_element",
"(",
"'notification_type'",
")",
".",
"text",
"=",
"NOTIFICATION_TYPES",
"[",
"self_service_notification_type",
"]",
"if",
"self_service_notification_type",
"notif",
".",
"add_element",
"(",
"'notification_subject'",
")",
".",
"text",
"=",
"self_service_notification_subject",
"if",
"self_service_notification_subject",
"notif",
".",
"add_element",
"(",
"'notification_message'",
")",
".",
"text",
"=",
"self_service_notification_message",
"if",
"self_service_notification_message",
"return",
"unless",
"@self_service_data_config",
"[",
":notification_reminders",
"]",
"reminds",
"=",
"notif",
".",
"add_element",
"(",
"'reminders'",
")",
"reminds",
".",
"add_element",
"(",
"'notification_reminders_enabled'",
")",
".",
"text",
"=",
"self_service_reminders_enabled",
".",
"to_s",
"reminds",
".",
"add_element",
"(",
"'notification_reminder_frequency'",
")",
".",
"text",
"=",
"self_service_reminder_frequency",
".",
"to_s",
"if",
"self_service_reminder_frequency",
"end"
] |
set ssvc notification settings in xml
|
[
"set",
"ssvc",
"notification",
"settings",
"in",
"xml"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L891-L915
|
15,856
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.validate_user_removable
|
def validate_user_removable(new_val)
raise JSS::UnsupportedError, 'User removal settings not applicable to this class' unless self_service_payload == :profile
raise JSS::UnsupportedError, 'Removal :with_auth not applicable to this class' if new_val == :with_auth && !self_service_targets.include?(:ios)
raise JSS::InvalidDataError, "Value must be one of: :#{PROFILE_REMOVAL_BY_USER.keys.join(', :')}" unless PROFILE_REMOVAL_BY_USER.key?(new_val)
end
|
ruby
|
def validate_user_removable(new_val)
raise JSS::UnsupportedError, 'User removal settings not applicable to this class' unless self_service_payload == :profile
raise JSS::UnsupportedError, 'Removal :with_auth not applicable to this class' if new_val == :with_auth && !self_service_targets.include?(:ios)
raise JSS::InvalidDataError, "Value must be one of: :#{PROFILE_REMOVAL_BY_USER.keys.join(', :')}" unless PROFILE_REMOVAL_BY_USER.key?(new_val)
end
|
[
"def",
"validate_user_removable",
"(",
"new_val",
")",
"raise",
"JSS",
"::",
"UnsupportedError",
",",
"'User removal settings not applicable to this class'",
"unless",
"self_service_payload",
"==",
":profile",
"raise",
"JSS",
"::",
"UnsupportedError",
",",
"'Removal :with_auth not applicable to this class'",
"if",
"new_val",
"==",
":with_auth",
"&&",
"!",
"self_service_targets",
".",
"include?",
"(",
":ios",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"Value must be one of: :#{PROFILE_REMOVAL_BY_USER.keys.join(', :')}\"",
"unless",
"PROFILE_REMOVAL_BY_USER",
".",
"key?",
"(",
"new_val",
")",
"end"
] |
Raise an error if user_removable settings are wrong
|
[
"Raise",
"an",
"error",
"if",
"user_removable",
"settings",
"are",
"wrong"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L918-L924
|
15,857
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/self_servable.rb
|
JSS.SelfServable.validate_icon
|
def validate_icon(id)
return nil unless JSS::DB_CNX.connected?
raise JSS::NoSuchItemError, "No icon with id #{id}" unless JSS::Icon.all_ids.include? id
end
|
ruby
|
def validate_icon(id)
return nil unless JSS::DB_CNX.connected?
raise JSS::NoSuchItemError, "No icon with id #{id}" unless JSS::Icon.all_ids.include? id
end
|
[
"def",
"validate_icon",
"(",
"id",
")",
"return",
"nil",
"unless",
"JSS",
"::",
"DB_CNX",
".",
"connected?",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No icon with id #{id}\"",
"unless",
"JSS",
"::",
"Icon",
".",
"all_ids",
".",
"include?",
"id",
"end"
] |
Raise an error if an icon id is not valid
|
[
"Raise",
"an",
"error",
"if",
"an",
"icon",
"id",
"is",
"not",
"valid"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/self_servable.rb#L927-L930
|
15,858
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/advanced_search.rb
|
JSS.AdvancedSearch.update
|
def update(get_results = false)
orig_timeout = @api.cnx.options[:timeout]
@api.timeout = 1800
super()
requery_search_results if get_results
@api.timeout = orig_timeout
@id # remember to return the id
end
|
ruby
|
def update(get_results = false)
orig_timeout = @api.cnx.options[:timeout]
@api.timeout = 1800
super()
requery_search_results if get_results
@api.timeout = orig_timeout
@id # remember to return the id
end
|
[
"def",
"update",
"(",
"get_results",
"=",
"false",
")",
"orig_timeout",
"=",
"@api",
".",
"cnx",
".",
"options",
"[",
":timeout",
"]",
"@api",
".",
"timeout",
"=",
"1800",
"super",
"(",
")",
"requery_search_results",
"if",
"get_results",
"@api",
".",
"timeout",
"=",
"orig_timeout",
"@id",
"# remember to return the id",
"end"
] |
Save any changes
If get_results is true, they'll be available in {#search_results}. This might be slow.
@param get_results[Boolean] should the results of the search be queried immediately?
@return [Integer] the id of the updated search
|
[
"Save",
"any",
"changes"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/advanced_search.rb#L191-L199
|
15,859
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/advanced_search.rb
|
JSS.AdvancedSearch.requery_search_results
|
def requery_search_results
orig_open_timeout = @api.cnx.options[:open_timeout]
orig_timeout = @api.cnx.options[:timeout]
@api.timeout = 1800
@api.open_timeout = 1800
begin
requery = self.class.fetch(id: @id)
@search_results = requery.search_results
@result_display_keys = requery.result_display_keys
ensure
@api.timeout = orig_timeout
@api.open_timeout = orig_open_timeout
end
end
|
ruby
|
def requery_search_results
orig_open_timeout = @api.cnx.options[:open_timeout]
orig_timeout = @api.cnx.options[:timeout]
@api.timeout = 1800
@api.open_timeout = 1800
begin
requery = self.class.fetch(id: @id)
@search_results = requery.search_results
@result_display_keys = requery.result_display_keys
ensure
@api.timeout = orig_timeout
@api.open_timeout = orig_open_timeout
end
end
|
[
"def",
"requery_search_results",
"orig_open_timeout",
"=",
"@api",
".",
"cnx",
".",
"options",
"[",
":open_timeout",
"]",
"orig_timeout",
"=",
"@api",
".",
"cnx",
".",
"options",
"[",
":timeout",
"]",
"@api",
".",
"timeout",
"=",
"1800",
"@api",
".",
"open_timeout",
"=",
"1800",
"begin",
"requery",
"=",
"self",
".",
"class",
".",
"fetch",
"(",
"id",
":",
"@id",
")",
"@search_results",
"=",
"requery",
".",
"search_results",
"@result_display_keys",
"=",
"requery",
".",
"result_display_keys",
"ensure",
"@api",
".",
"timeout",
"=",
"orig_timeout",
"@api",
".",
"open_timeout",
"=",
"orig_open_timeout",
"end",
"end"
] |
Requery the API for the search results.
This can be very slow, so temporarily reset the API timeout to 30 minutes
@return [Array<Hash>] the new search results
|
[
"Requery",
"the",
"API",
"for",
"the",
"search",
"results",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/advanced_search.rb#L207-L220
|
15,860
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/advanced_search.rb
|
JSS.AdvancedSearch.display_fields=
|
def display_fields=(new_val)
raise JSS::InvalidDataError, 'display_fields must be an Array.' unless new_val.is_a? Array
return if new_val.sort == @display_fields.sort
@display_fields = new_val
@need_to_update = true
end
|
ruby
|
def display_fields=(new_val)
raise JSS::InvalidDataError, 'display_fields must be an Array.' unless new_val.is_a? Array
return if new_val.sort == @display_fields.sort
@display_fields = new_val
@need_to_update = true
end
|
[
"def",
"display_fields",
"=",
"(",
"new_val",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'display_fields must be an Array.'",
"unless",
"new_val",
".",
"is_a?",
"Array",
"return",
"if",
"new_val",
".",
"sort",
"==",
"@display_fields",
".",
"sort",
"@display_fields",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set the list of fields to be retrieved with the
search results.
@param new_val[Array<String>] the new field names
|
[
"Set",
"the",
"list",
"of",
"fields",
"to",
"be",
"retrieved",
"with",
"the",
"search",
"results",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/advanced_search.rb#L244-L249
|
15,861
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/advanced_search.rb
|
JSS.AdvancedSearch.export
|
def export(output_file, format = :csv, overwrite = false)
raise JSS::InvalidDataError, "Export format must be one of: :#{EXPORT_FORMATS.join ', :'}" unless EXPORT_FORMATS.include? format
out = Pathname.new output_file
unless overwrite
raise JSS::AlreadyExistsError, "The output file already exists: #{out}" if out.exist?
end
case format
when :csv
require 'csv'
CSV.open(out.to_s, 'wb') do |csv|
csv << @result_display_keys
@search_results.each do |row|
csv << @result_display_keys.map { |key| row[key] }
end # each do row
end # CSV.open
when :tab
tabbed = @result_display_keys.join("\t") + "\n"
@search_results.each do |row|
tabbed << @result_display_keys.map { |key| row[key] }.join("\t") + "\n"
end # each do row
out.jss_save tabbed.chomp
else # :xml
doc = REXML::Document.new '<?xml version="1.0" encoding="ISO-8859-1"?>'
members = doc.add_element self.class::RESULT_CLASS::RSRC_LIST_KEY.to_s
@search_results.each do |row|
member = members.add_element self.class::RESULT_CLASS::RSRC_OBJECT_KEY.to_s
@result_display_keys.each do |field|
member.add_element(field.to_s.tr(' ', '_')).text = row[field].empty? ? nil : row[field]
end # ech do field
end # each do row
out.jss_save doc.to_s.gsub('><', ">\n<")
end # case
out
end
|
ruby
|
def export(output_file, format = :csv, overwrite = false)
raise JSS::InvalidDataError, "Export format must be one of: :#{EXPORT_FORMATS.join ', :'}" unless EXPORT_FORMATS.include? format
out = Pathname.new output_file
unless overwrite
raise JSS::AlreadyExistsError, "The output file already exists: #{out}" if out.exist?
end
case format
when :csv
require 'csv'
CSV.open(out.to_s, 'wb') do |csv|
csv << @result_display_keys
@search_results.each do |row|
csv << @result_display_keys.map { |key| row[key] }
end # each do row
end # CSV.open
when :tab
tabbed = @result_display_keys.join("\t") + "\n"
@search_results.each do |row|
tabbed << @result_display_keys.map { |key| row[key] }.join("\t") + "\n"
end # each do row
out.jss_save tabbed.chomp
else # :xml
doc = REXML::Document.new '<?xml version="1.0" encoding="ISO-8859-1"?>'
members = doc.add_element self.class::RESULT_CLASS::RSRC_LIST_KEY.to_s
@search_results.each do |row|
member = members.add_element self.class::RESULT_CLASS::RSRC_OBJECT_KEY.to_s
@result_display_keys.each do |field|
member.add_element(field.to_s.tr(' ', '_')).text = row[field].empty? ? nil : row[field]
end # ech do field
end # each do row
out.jss_save doc.to_s.gsub('><', ">\n<")
end # case
out
end
|
[
"def",
"export",
"(",
"output_file",
",",
"format",
"=",
":csv",
",",
"overwrite",
"=",
"false",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"Export format must be one of: :#{EXPORT_FORMATS.join ', :'}\"",
"unless",
"EXPORT_FORMATS",
".",
"include?",
"format",
"out",
"=",
"Pathname",
".",
"new",
"output_file",
"unless",
"overwrite",
"raise",
"JSS",
"::",
"AlreadyExistsError",
",",
"\"The output file already exists: #{out}\"",
"if",
"out",
".",
"exist?",
"end",
"case",
"format",
"when",
":csv",
"require",
"'csv'",
"CSV",
".",
"open",
"(",
"out",
".",
"to_s",
",",
"'wb'",
")",
"do",
"|",
"csv",
"|",
"csv",
"<<",
"@result_display_keys",
"@search_results",
".",
"each",
"do",
"|",
"row",
"|",
"csv",
"<<",
"@result_display_keys",
".",
"map",
"{",
"|",
"key",
"|",
"row",
"[",
"key",
"]",
"}",
"end",
"# each do row",
"end",
"# CSV.open",
"when",
":tab",
"tabbed",
"=",
"@result_display_keys",
".",
"join",
"(",
"\"\\t\"",
")",
"+",
"\"\\n\"",
"@search_results",
".",
"each",
"do",
"|",
"row",
"|",
"tabbed",
"<<",
"@result_display_keys",
".",
"map",
"{",
"|",
"key",
"|",
"row",
"[",
"key",
"]",
"}",
".",
"join",
"(",
"\"\\t\"",
")",
"+",
"\"\\n\"",
"end",
"# each do row",
"out",
".",
"jss_save",
"tabbed",
".",
"chomp",
"else",
"# :xml",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"'<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>'",
"members",
"=",
"doc",
".",
"add_element",
"self",
".",
"class",
"::",
"RESULT_CLASS",
"::",
"RSRC_LIST_KEY",
".",
"to_s",
"@search_results",
".",
"each",
"do",
"|",
"row",
"|",
"member",
"=",
"members",
".",
"add_element",
"self",
".",
"class",
"::",
"RESULT_CLASS",
"::",
"RSRC_OBJECT_KEY",
".",
"to_s",
"@result_display_keys",
".",
"each",
"do",
"|",
"field",
"|",
"member",
".",
"add_element",
"(",
"field",
".",
"to_s",
".",
"tr",
"(",
"' '",
",",
"'_'",
")",
")",
".",
"text",
"=",
"row",
"[",
"field",
"]",
".",
"empty?",
"?",
"nil",
":",
"row",
"[",
"field",
"]",
"end",
"# ech do field",
"end",
"# each do row",
"out",
".",
"jss_save",
"doc",
".",
"to_s",
".",
"gsub",
"(",
"'><'",
",",
"\">\\n<\"",
")",
"end",
"# case",
"out",
"end"
] |
Export the display fields of the search results to a file.
@param output_file[String,Pathname] The file in which to store the exported results
@param format[Symbol] one of :csv, :tab, or :xml, defaults to :csv
@param overwrite[Boolean] should the output_file be overwrite if it exists? Defaults to false
@return [Pathname] the path to the output file
@note This method only exports the display fields defined in this advanced search for
the search_result members (computers, mobile_devices, or users)
It doesn't currently provide the ability to export subsets of info about those objects, as the
Web UI does (e.g. group memberships, applications, receipts, etc)
|
[
"Export",
"the",
"display",
"fields",
"of",
"the",
"search",
"results",
"to",
"a",
"file",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/advanced_search.rb#L272-L311
|
15,862
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/advanced_search.rb
|
JSS.AdvancedSearch.rest_xml
|
def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
acs = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
acs.add_element('name').text = @name
acs.add_element('sort_1').text = @sort_1 if @sort_1
acs.add_element('sort_2').text = @sort_2 if @sort_2
acs.add_element('sort_3').text = @sort_3 if @sort_3
acs << @criteria.rest_xml
df = acs.add_element('display_fields')
@display_fields.each { |f| df.add_element('display_field').add_element('name').text = f }
add_site_to_xml(doc)
doc.to_s
end
|
ruby
|
def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
acs = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
acs.add_element('name').text = @name
acs.add_element('sort_1').text = @sort_1 if @sort_1
acs.add_element('sort_2').text = @sort_2 if @sort_2
acs.add_element('sort_3').text = @sort_3 if @sort_3
acs << @criteria.rest_xml
df = acs.add_element('display_fields')
@display_fields.each { |f| df.add_element('display_field').add_element('name').text = f }
add_site_to_xml(doc)
doc.to_s
end
|
[
"def",
"rest_xml",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"APIConnection",
"::",
"XML_HEADER",
"acs",
"=",
"doc",
".",
"add_element",
"self",
".",
"class",
"::",
"RSRC_OBJECT_KEY",
".",
"to_s",
"acs",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"@name",
"acs",
".",
"add_element",
"(",
"'sort_1'",
")",
".",
"text",
"=",
"@sort_1",
"if",
"@sort_1",
"acs",
".",
"add_element",
"(",
"'sort_2'",
")",
".",
"text",
"=",
"@sort_2",
"if",
"@sort_2",
"acs",
".",
"add_element",
"(",
"'sort_3'",
")",
".",
"text",
"=",
"@sort_3",
"if",
"@sort_3",
"acs",
"<<",
"@criteria",
".",
"rest_xml",
"df",
"=",
"acs",
".",
"add_element",
"(",
"'display_fields'",
")",
"@display_fields",
".",
"each",
"{",
"|",
"f",
"|",
"df",
".",
"add_element",
"(",
"'display_field'",
")",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"f",
"}",
"add_site_to_xml",
"(",
"doc",
")",
"doc",
".",
"to_s",
"end"
] |
Clean up the inconsistent "Display Field" keys in the search results.
Sometimes spaces have been converted to underscores, sometimes not, sometimes both.
Same for dashes.
E.g :"Last Check-in"/:Last_Check_in/:"Last_Check-in", :Computer_Name, and :"Display Name"/:Display_Name
This ensures there's always the fully underscored version.
Update an internally used array of the display field names, symbolized, with
spaces and dashes converted to underscores. We use these
to overcome inconsistencies in how the names come from the API
@return [void]
def standardize_display_field_keys
spdash =
us =
@display_field_std_keys = @display_fields.map { |f| f.gsub(/ |-/, '_').to_sym }
end
|
[
"Clean",
"up",
"the",
"inconsistent",
"Display",
"Field",
"keys",
"in",
"the",
"search",
"results",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/advanced_search.rb#L337-L351
|
15,863
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mobile_device_application.rb
|
JSS.MobileDeviceApplication.deploy_as_managed_app=
|
def deploy_as_managed_app=(new_val)
return nil if new_val == @deploy_as_managed_app
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@deploy_as_managed_app = new_val
@need_to_update = true
end
|
ruby
|
def deploy_as_managed_app=(new_val)
return nil if new_val == @deploy_as_managed_app
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@deploy_as_managed_app = new_val
@need_to_update = true
end
|
[
"def",
"deploy_as_managed_app",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@deploy_as_managed_app",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be true or false'",
"unless",
"new_val",
".",
"jss_boolean?",
"@deploy_as_managed_app",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set whether or not this app should be deployed as managed
@param new_val[Boolean] The new value
@return [void]
|
[
"Set",
"whether",
"or",
"not",
"this",
"app",
"should",
"be",
"deployed",
"as",
"managed"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mobile_device_application.rb#L284-L289
|
15,864
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mobile_device_application.rb
|
JSS.MobileDeviceApplication.remove_app_when_mdm_profile_is_removed=
|
def remove_app_when_mdm_profile_is_removed=(new_val)
return nil if new_val == @remove_app_when_mdm_profile_is_removed
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@remove_app_when_mdm_profile_is_removed = new_val
@need_to_update = true
end
|
ruby
|
def remove_app_when_mdm_profile_is_removed=(new_val)
return nil if new_val == @remove_app_when_mdm_profile_is_removed
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@remove_app_when_mdm_profile_is_removed = new_val
@need_to_update = true
end
|
[
"def",
"remove_app_when_mdm_profile_is_removed",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@remove_app_when_mdm_profile_is_removed",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be true or false'",
"unless",
"new_val",
".",
"jss_boolean?",
"@remove_app_when_mdm_profile_is_removed",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set whether or not this app should be removed when
the device is unmanaged
@param new_val[Boolean] The new value
@return [void]
|
[
"Set",
"whether",
"or",
"not",
"this",
"app",
"should",
"be",
"removed",
"when",
"the",
"device",
"is",
"unmanaged"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mobile_device_application.rb#L299-L304
|
15,865
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mobile_device_application.rb
|
JSS.MobileDeviceApplication.prevent_backup_of_app_data=
|
def prevent_backup_of_app_data=(new_val)
return nil if new_val == @prevent_backup_of_app_data
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@prevent_backup_of_app_data = new_val
@need_to_update = true
end
|
ruby
|
def prevent_backup_of_app_data=(new_val)
return nil if new_val == @prevent_backup_of_app_data
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@prevent_backup_of_app_data = new_val
@need_to_update = true
end
|
[
"def",
"prevent_backup_of_app_data",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@prevent_backup_of_app_data",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be true or false'",
"unless",
"new_val",
".",
"jss_boolean?",
"@prevent_backup_of_app_data",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set whether or not the device should back up this app's data
@param new_val[Boolean] The new value
@return [void]
|
[
"Set",
"whether",
"or",
"not",
"the",
"device",
"should",
"back",
"up",
"this",
"app",
"s",
"data"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mobile_device_application.rb#L312-L317
|
15,866
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mobile_device_application.rb
|
JSS.MobileDeviceApplication.keep_description_and_icon_up_to_date=
|
def keep_description_and_icon_up_to_date=(new_val)
return nil if new_val == @keep_description_and_icon_up_to_date
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@keep_description_and_icon_up_to_date = new_val
@need_to_update = true
end
|
ruby
|
def keep_description_and_icon_up_to_date=(new_val)
return nil if new_val == @keep_description_and_icon_up_to_date
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@keep_description_and_icon_up_to_date = new_val
@need_to_update = true
end
|
[
"def",
"keep_description_and_icon_up_to_date",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@keep_description_and_icon_up_to_date",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be true or false'",
"unless",
"new_val",
".",
"jss_boolean?",
"@keep_description_and_icon_up_to_date",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set whether or not the jss should update info about this app from the app store
@param new_val[Boolean] The new value
@return [void]
|
[
"Set",
"whether",
"or",
"not",
"the",
"jss",
"should",
"update",
"info",
"about",
"this",
"app",
"from",
"the",
"app",
"store"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mobile_device_application.rb#L326-L331
|
15,867
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mobile_device_application.rb
|
JSS.MobileDeviceApplication.free=
|
def free=(new_val)
return nil if new_val == @free
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@free = new_val
@need_to_update = true
end
|
ruby
|
def free=(new_val)
return nil if new_val == @free
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@free = new_val
@need_to_update = true
end
|
[
"def",
"free",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@free",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be true or false'",
"unless",
"new_val",
".",
"jss_boolean?",
"@free",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set whether or not this is a free app
@param new_val[Boolean] The new value
@return [void]
|
[
"Set",
"whether",
"or",
"not",
"this",
"is",
"a",
"free",
"app"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mobile_device_application.rb#L339-L344
|
15,868
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mobile_device_application.rb
|
JSS.MobileDeviceApplication.take_over_management=
|
def take_over_management=(new_val)
return nil if new_val == @take_over_management
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@take_over_management = new_val
@need_to_update = true
end
|
ruby
|
def take_over_management=(new_val)
return nil if new_val == @take_over_management
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@take_over_management = new_val
@need_to_update = true
end
|
[
"def",
"take_over_management",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@take_over_management",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be true or false'",
"unless",
"new_val",
".",
"jss_boolean?",
"@take_over_management",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set whether or not Jamf should manage this app even if the user installed
it on their own.
@param new_val[Boolean] The new value
@return [void]
|
[
"Set",
"whether",
"or",
"not",
"Jamf",
"should",
"manage",
"this",
"app",
"even",
"if",
"the",
"user",
"installed",
"it",
"on",
"their",
"own",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mobile_device_application.rb#L353-L358
|
15,869
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mobile_device_application.rb
|
JSS.MobileDeviceApplication.host_externally=
|
def host_externally=(new_val)
return nil if new_val == @host_externally
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@host_externally = new_val
@need_to_update = true
end
|
ruby
|
def host_externally=(new_val)
return nil if new_val == @host_externally
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@host_externally = new_val
@need_to_update = true
end
|
[
"def",
"host_externally",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@host_externally",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be true or false'",
"unless",
"new_val",
".",
"jss_boolean?",
"@host_externally",
"=",
"new_val",
"@need_to_update",
"=",
"true",
"end"
] |
Set whether or not this app's .ipa is hosted outside the Jamf server
@param new_val[Boolean] The new value
@return [void]
|
[
"Set",
"whether",
"or",
"not",
"this",
"app",
"s",
".",
"ipa",
"is",
"hosted",
"outside",
"the",
"Jamf",
"server"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mobile_device_application.rb#L390-L395
|
15,870
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/mobile_device_application.rb
|
JSS.MobileDeviceApplication.save_ipa
|
def save_ipa(path, overwrite = false)
return nil unless @ipa[:data]
path = Pathname.new path
path = path + @ipa[:name] if path.directory? && @ipa[:name]
raise JSS::AlreadyExistsError, "The file #{path} already exists" if path.exist? && !overwrite
path.delete if path.exist?
path.jss_save Base64.decode64(@ipa[:data])
end
|
ruby
|
def save_ipa(path, overwrite = false)
return nil unless @ipa[:data]
path = Pathname.new path
path = path + @ipa[:name] if path.directory? && @ipa[:name]
raise JSS::AlreadyExistsError, "The file #{path} already exists" if path.exist? && !overwrite
path.delete if path.exist?
path.jss_save Base64.decode64(@ipa[:data])
end
|
[
"def",
"save_ipa",
"(",
"path",
",",
"overwrite",
"=",
"false",
")",
"return",
"nil",
"unless",
"@ipa",
"[",
":data",
"]",
"path",
"=",
"Pathname",
".",
"new",
"path",
"path",
"=",
"path",
"+",
"@ipa",
"[",
":name",
"]",
"if",
"path",
".",
"directory?",
"&&",
"@ipa",
"[",
":name",
"]",
"raise",
"JSS",
"::",
"AlreadyExistsError",
",",
"\"The file #{path} already exists\"",
"if",
"path",
".",
"exist?",
"&&",
"!",
"overwrite",
"path",
".",
"delete",
"if",
"path",
".",
"exist?",
"path",
".",
"jss_save",
"Base64",
".",
"decode64",
"(",
"@ipa",
"[",
":data",
"]",
")",
"end"
] |
Save the application to a file.
@param path[Pathname, String] The path to which the file should be saved.
If the path given is an existing directory, the ipa's current filename will
be used, if known.
@param overwrite[Boolean] Overwrite the file if it exists? Defaults to false
@return [void]
|
[
"Save",
"the",
"application",
"to",
"a",
"file",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/mobile_device_application.rb#L433-L441
|
15,871
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/computer.rb
|
JSS.Computer.management_data
|
def management_data(subset: nil, only: nil)
raise JSS::NoSuchItemError, 'Computer not yet saved in the JSS' unless @in_jss
JSS::Computer.management_data @id, subset: subset, only: only, api: @api
end
|
ruby
|
def management_data(subset: nil, only: nil)
raise JSS::NoSuchItemError, 'Computer not yet saved in the JSS' unless @in_jss
JSS::Computer.management_data @id, subset: subset, only: only, api: @api
end
|
[
"def",
"management_data",
"(",
"subset",
":",
"nil",
",",
"only",
":",
"nil",
")",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"'Computer not yet saved in the JSS'",
"unless",
"@in_jss",
"JSS",
"::",
"Computer",
".",
"management_data",
"@id",
",",
"subset",
":",
"subset",
",",
"only",
":",
"only",
",",
"api",
":",
"@api",
"end"
] |
app usage
The 'computer management' data for this computer
NOTE: the data isn't cached locally, and the API is queried every time
@see {JSS::Computer.management_data} for details
|
[
"app",
"usage",
"The",
"computer",
"management",
"data",
"for",
"this",
"computer"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/computer.rb#L886-L889
|
15,872
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/computer.rb
|
JSS.Computer.set_management_to
|
def set_management_to(name, password)
password = nil unless name
@management_username = name
@management_password = password
@managed = name ? true : false
@need_to_update = true
end
|
ruby
|
def set_management_to(name, password)
password = nil unless name
@management_username = name
@management_password = password
@managed = name ? true : false
@need_to_update = true
end
|
[
"def",
"set_management_to",
"(",
"name",
",",
"password",
")",
"password",
"=",
"nil",
"unless",
"name",
"@management_username",
"=",
"name",
"@management_password",
"=",
"password",
"@managed",
"=",
"name",
"?",
"true",
":",
"false",
"@need_to_update",
"=",
"true",
"end"
] |
Set or unset management acct and password for this computer
@param name[String] the name of the management acct.
@param password[String] the password of the management acct
@return [void]
The changes will need to be pushed to the server with {#update}
before they take effect.
CAUTION: this does nothing to confirm the name and password
will work on the machine!
|
[
"Set",
"or",
"unset",
"management",
"acct",
"and",
"password",
"for",
"this",
"computer"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/computer.rb#L953-L959
|
15,873
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/computer.rb
|
JSS.Computer.rest_xml
|
def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
computer = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
general = computer.add_element('general')
general.add_element('name').text = @name
general.add_element('alt_mac_address').text = @alt_mac_address
general.add_element('asset_tag').text = @asset_tag
general.add_element('barcode_1').text = @barcode1
general.add_element('barcode_2').text = @barcode2
general.add_element('ip_address').text = @ip_address
general.add_element('mac_address').text = @mac_address
general.add_element('udid').text = @udid
general.add_element('serial_number').text = @serial_number
rmgmt = general.add_element('remote_management')
rmgmt.add_element('managed').text = @managed
rmgmt.add_element('management_username').text = @management_username
rmgmt.add_element('management_password').text = @management_password if @management_password
computer << ext_attr_xml if unsaved_eas?
computer << location_xml if has_location?
computer << purchasing_xml if has_purchasing?
add_site_to_xml(doc)
doc.to_s
end
|
ruby
|
def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
computer = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
general = computer.add_element('general')
general.add_element('name').text = @name
general.add_element('alt_mac_address').text = @alt_mac_address
general.add_element('asset_tag').text = @asset_tag
general.add_element('barcode_1').text = @barcode1
general.add_element('barcode_2').text = @barcode2
general.add_element('ip_address').text = @ip_address
general.add_element('mac_address').text = @mac_address
general.add_element('udid').text = @udid
general.add_element('serial_number').text = @serial_number
rmgmt = general.add_element('remote_management')
rmgmt.add_element('managed').text = @managed
rmgmt.add_element('management_username').text = @management_username
rmgmt.add_element('management_password').text = @management_password if @management_password
computer << ext_attr_xml if unsaved_eas?
computer << location_xml if has_location?
computer << purchasing_xml if has_purchasing?
add_site_to_xml(doc)
doc.to_s
end
|
[
"def",
"rest_xml",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"APIConnection",
"::",
"XML_HEADER",
"computer",
"=",
"doc",
".",
"add_element",
"self",
".",
"class",
"::",
"RSRC_OBJECT_KEY",
".",
"to_s",
"general",
"=",
"computer",
".",
"add_element",
"(",
"'general'",
")",
"general",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"@name",
"general",
".",
"add_element",
"(",
"'alt_mac_address'",
")",
".",
"text",
"=",
"@alt_mac_address",
"general",
".",
"add_element",
"(",
"'asset_tag'",
")",
".",
"text",
"=",
"@asset_tag",
"general",
".",
"add_element",
"(",
"'barcode_1'",
")",
".",
"text",
"=",
"@barcode1",
"general",
".",
"add_element",
"(",
"'barcode_2'",
")",
".",
"text",
"=",
"@barcode2",
"general",
".",
"add_element",
"(",
"'ip_address'",
")",
".",
"text",
"=",
"@ip_address",
"general",
".",
"add_element",
"(",
"'mac_address'",
")",
".",
"text",
"=",
"@mac_address",
"general",
".",
"add_element",
"(",
"'udid'",
")",
".",
"text",
"=",
"@udid",
"general",
".",
"add_element",
"(",
"'serial_number'",
")",
".",
"text",
"=",
"@serial_number",
"rmgmt",
"=",
"general",
".",
"add_element",
"(",
"'remote_management'",
")",
"rmgmt",
".",
"add_element",
"(",
"'managed'",
")",
".",
"text",
"=",
"@managed",
"rmgmt",
".",
"add_element",
"(",
"'management_username'",
")",
".",
"text",
"=",
"@management_username",
"rmgmt",
".",
"add_element",
"(",
"'management_password'",
")",
".",
"text",
"=",
"@management_password",
"if",
"@management_password",
"computer",
"<<",
"ext_attr_xml",
"if",
"unsaved_eas?",
"computer",
"<<",
"location_xml",
"if",
"has_location?",
"computer",
"<<",
"purchasing_xml",
"if",
"has_purchasing?",
"add_site_to_xml",
"(",
"doc",
")",
"doc",
".",
"to_s",
"end"
] |
Return a String with the XML Resource
for submitting changes to the JSS via
the API
For Computers, only some items can be changed via the API
In particular, any data gatherd by a Recon cannot be changed
|
[
"Return",
"a",
"String",
"with",
"the",
"XML",
"Resource",
"for",
"submitting",
"changes",
"to",
"the",
"JSS",
"via",
"the",
"API"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/computer.rb#L1113-L1142
|
15,874
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.get_rsrc
|
def get_rsrc(rsrc, format = :json)
# puts object_id
validate_connected
raise JSS::InvalidDataError, 'format must be :json or :xml' unless %i[json xml].include? format
# TODO: fix what rubocop is complaining about in the line below.
# (I doubt we want to CGI.escape the whole resource)
rsrc = URI.encode rsrc
begin
@last_http_response = @cnx[rsrc].get(accept: format)
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
# TODO: make sure we're returning the String version of the
# response (i.e. its body) here and in POST, PUT, DELETE.
format == :json ? JSON.parse(@last_http_response, symbolize_names: true) : @last_http_response
end
|
ruby
|
def get_rsrc(rsrc, format = :json)
# puts object_id
validate_connected
raise JSS::InvalidDataError, 'format must be :json or :xml' unless %i[json xml].include? format
# TODO: fix what rubocop is complaining about in the line below.
# (I doubt we want to CGI.escape the whole resource)
rsrc = URI.encode rsrc
begin
@last_http_response = @cnx[rsrc].get(accept: format)
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
# TODO: make sure we're returning the String version of the
# response (i.e. its body) here and in POST, PUT, DELETE.
format == :json ? JSON.parse(@last_http_response, symbolize_names: true) : @last_http_response
end
|
[
"def",
"get_rsrc",
"(",
"rsrc",
",",
"format",
"=",
":json",
")",
"# puts object_id",
"validate_connected",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'format must be :json or :xml'",
"unless",
"%i[",
"json",
"xml",
"]",
".",
"include?",
"format",
"# TODO: fix what rubocop is complaining about in the line below.",
"# (I doubt we want to CGI.escape the whole resource)",
"rsrc",
"=",
"URI",
".",
"encode",
"rsrc",
"begin",
"@last_http_response",
"=",
"@cnx",
"[",
"rsrc",
"]",
".",
"get",
"(",
"accept",
":",
"format",
")",
"rescue",
"RestClient",
"::",
"ExceptionWithResponse",
"=>",
"e",
"handle_http_error",
"e",
"end",
"# TODO: make sure we're returning the String version of the",
"# response (i.e. its body) here and in POST, PUT, DELETE.",
"format",
"==",
":json",
"?",
"JSON",
".",
"parse",
"(",
"@last_http_response",
",",
"symbolize_names",
":",
"true",
")",
":",
"@last_http_response",
"end"
] |
disconnect
Get an arbitrary JSS resource
The first argument is the resource to get (the part of the API url
after the 'JSSResource/' )
By default we get the data in JSON, and parse it
into a ruby data structure (arrays, hashes, strings, etc)
with symbolized Hash keys.
@param rsrc[String] the resource to get
(the part of the API url after the 'JSSResource/' )
@param format[Symbol] either ;json or :xml
If the second argument is :xml, the XML data is returned as a String.
@return [Hash,String] the result of the get
|
[
"disconnect",
"Get",
"an",
"arbitrary",
"JSS",
"resource"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L525-L542
|
15,875
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.put_rsrc
|
def put_rsrc(rsrc, xml)
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ')
# send the data
@last_http_response = @cnx[rsrc].put(xml, content_type: 'text/xml')
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
|
ruby
|
def put_rsrc(rsrc, xml)
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ')
# send the data
@last_http_response = @cnx[rsrc].put(xml, content_type: 'text/xml')
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
|
[
"def",
"put_rsrc",
"(",
"rsrc",
",",
"xml",
")",
"validate_connected",
"# convert CRs & to ",
"xml",
".",
"gsub!",
"(",
"/",
"\\r",
"/",
",",
"' '",
")",
"# send the data",
"@last_http_response",
"=",
"@cnx",
"[",
"rsrc",
"]",
".",
"put",
"(",
"xml",
",",
"content_type",
":",
"'text/xml'",
")",
"rescue",
"RestClient",
"::",
"ExceptionWithResponse",
"=>",
"e",
"handle_http_error",
"e",
"end"
] |
Change an existing JSS resource
@param rsrc[String] the API resource being changed, the URL part after 'JSSResource/'
@param xml[String] the xml specifying the changes.
@return [String] the xml response from the server.
|
[
"Change",
"an",
"existing",
"JSS",
"resource"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L552-L562
|
15,876
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.post_rsrc
|
def post_rsrc(rsrc, xml = '')
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ') if xml
# send the data
@last_http_response = @cnx[rsrc].post xml, content_type: 'text/xml', accept: :json
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
|
ruby
|
def post_rsrc(rsrc, xml = '')
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ') if xml
# send the data
@last_http_response = @cnx[rsrc].post xml, content_type: 'text/xml', accept: :json
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
|
[
"def",
"post_rsrc",
"(",
"rsrc",
",",
"xml",
"=",
"''",
")",
"validate_connected",
"# convert CRs & to ",
"xml",
".",
"gsub!",
"(",
"/",
"\\r",
"/",
",",
"' '",
")",
"if",
"xml",
"# send the data",
"@last_http_response",
"=",
"@cnx",
"[",
"rsrc",
"]",
".",
"post",
"xml",
",",
"content_type",
":",
"'text/xml'",
",",
"accept",
":",
":json",
"rescue",
"RestClient",
"::",
"ExceptionWithResponse",
"=>",
"e",
"handle_http_error",
"e",
"end"
] |
Create a new JSS resource
@param rsrc[String] the API resource being created, the URL part after 'JSSResource/'
@param xml[String] the xml specifying the new object.
@return [String] the xml response from the server.
|
[
"Create",
"a",
"new",
"JSS",
"resource"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L572-L582
|
15,877
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.delete_rsrc
|
def delete_rsrc(rsrc, xml = nil)
validate_connected
raise MissingDataError, 'Missing :rsrc' if rsrc.nil?
# payload?
return delete_with_payload rsrc, xml if xml
# delete the resource
@last_http_response = @cnx[rsrc].delete
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
|
ruby
|
def delete_rsrc(rsrc, xml = nil)
validate_connected
raise MissingDataError, 'Missing :rsrc' if rsrc.nil?
# payload?
return delete_with_payload rsrc, xml if xml
# delete the resource
@last_http_response = @cnx[rsrc].delete
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
|
[
"def",
"delete_rsrc",
"(",
"rsrc",
",",
"xml",
"=",
"nil",
")",
"validate_connected",
"raise",
"MissingDataError",
",",
"'Missing :rsrc'",
"if",
"rsrc",
".",
"nil?",
"# payload?",
"return",
"delete_with_payload",
"rsrc",
",",
"xml",
"if",
"xml",
"# delete the resource",
"@last_http_response",
"=",
"@cnx",
"[",
"rsrc",
"]",
".",
"delete",
"rescue",
"RestClient",
"::",
"ExceptionWithResponse",
"=>",
"e",
"handle_http_error",
"e",
"end"
] |
post_rsrc
Delete a resource from the JSS
@param rsrc[String] the resource to create, the URL part after 'JSSResource/'
@return [String] the xml response from the server.
|
[
"post_rsrc",
"Delete",
"a",
"resource",
"from",
"the",
"JSS"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L590-L601
|
15,878
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.master_distribution_point
|
def master_distribution_point(refresh = false)
@master_distribution_point = nil if refresh
return @master_distribution_point if @master_distribution_point
all_dps = JSS::DistributionPoint.all refresh, api: self
@master_distribution_point =
case all_dps.size
when 0
raise JSS::NoSuchItemError, 'No distribution points defined'
when 1
JSS::DistributionPoint.fetch id: all_dps.first[:id], api: self
else
JSS::DistributionPoint.fetch id: :master, api: self
end
end
|
ruby
|
def master_distribution_point(refresh = false)
@master_distribution_point = nil if refresh
return @master_distribution_point if @master_distribution_point
all_dps = JSS::DistributionPoint.all refresh, api: self
@master_distribution_point =
case all_dps.size
when 0
raise JSS::NoSuchItemError, 'No distribution points defined'
when 1
JSS::DistributionPoint.fetch id: all_dps.first[:id], api: self
else
JSS::DistributionPoint.fetch id: :master, api: self
end
end
|
[
"def",
"master_distribution_point",
"(",
"refresh",
"=",
"false",
")",
"@master_distribution_point",
"=",
"nil",
"if",
"refresh",
"return",
"@master_distribution_point",
"if",
"@master_distribution_point",
"all_dps",
"=",
"JSS",
"::",
"DistributionPoint",
".",
"all",
"refresh",
",",
"api",
":",
"self",
"@master_distribution_point",
"=",
"case",
"all_dps",
".",
"size",
"when",
"0",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"'No distribution points defined'",
"when",
"1",
"JSS",
"::",
"DistributionPoint",
".",
"fetch",
"id",
":",
"all_dps",
".",
"first",
"[",
":id",
"]",
",",
"api",
":",
"self",
"else",
"JSS",
"::",
"DistributionPoint",
".",
"fetch",
"id",
":",
":master",
",",
"api",
":",
"self",
"end",
"end"
] |
Get the DistributionPoint instance for the master
distribution point in the JSS. If there's only one
in the JSS, return it even if not marked as master.
@param refresh[Boolean] re-read from the API?
@return [JSS::DistributionPoint]
|
[
"Get",
"the",
"DistributionPoint",
"instance",
"for",
"the",
"master",
"distribution",
"point",
"in",
"the",
"JSS",
".",
"If",
"there",
"s",
"only",
"one",
"in",
"the",
"JSS",
"return",
"it",
"even",
"if",
"not",
"marked",
"as",
"master",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L831-L846
|
15,879
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.my_distribution_point
|
def my_distribution_point(refresh = false)
@my_distribution_point = nil if refresh
return @my_distribution_point if @my_distribution_point
my_net_seg = my_network_segments[0]
@my_distribution_point = JSS::NetworkSegment.fetch(id: my_net_seg, api: self).distribution_point if my_net_seg
@my_distribution_point ||= master_distribution_point refresh
@my_distribution_point
end
|
ruby
|
def my_distribution_point(refresh = false)
@my_distribution_point = nil if refresh
return @my_distribution_point if @my_distribution_point
my_net_seg = my_network_segments[0]
@my_distribution_point = JSS::NetworkSegment.fetch(id: my_net_seg, api: self).distribution_point if my_net_seg
@my_distribution_point ||= master_distribution_point refresh
@my_distribution_point
end
|
[
"def",
"my_distribution_point",
"(",
"refresh",
"=",
"false",
")",
"@my_distribution_point",
"=",
"nil",
"if",
"refresh",
"return",
"@my_distribution_point",
"if",
"@my_distribution_point",
"my_net_seg",
"=",
"my_network_segments",
"[",
"0",
"]",
"@my_distribution_point",
"=",
"JSS",
"::",
"NetworkSegment",
".",
"fetch",
"(",
"id",
":",
"my_net_seg",
",",
"api",
":",
"self",
")",
".",
"distribution_point",
"if",
"my_net_seg",
"@my_distribution_point",
"||=",
"master_distribution_point",
"refresh",
"@my_distribution_point",
"end"
] |
Get the DistributionPoint instance for the machine running
this code, based on its IP address. If none is defined for this IP address,
use the result of master_distribution_point
@param refresh[Boolean] should the distribution point be re-queried?
@return [JSS::DistributionPoint]
|
[
"Get",
"the",
"DistributionPoint",
"instance",
"for",
"the",
"machine",
"running",
"this",
"code",
"based",
"on",
"its",
"IP",
"address",
".",
"If",
"none",
"is",
"defined",
"for",
"this",
"IP",
"address",
"use",
"the",
"result",
"of",
"master_distribution_point"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L856-L864
|
15,880
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.network_segments_for_ip
|
def network_segments_for_ip(ip)
ok_ip = IPAddr.new(ip)
matches = []
network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
matches
end
|
ruby
|
def network_segments_for_ip(ip)
ok_ip = IPAddr.new(ip)
matches = []
network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
matches
end
|
[
"def",
"network_segments_for_ip",
"(",
"ip",
")",
"ok_ip",
"=",
"IPAddr",
".",
"new",
"(",
"ip",
")",
"matches",
"=",
"[",
"]",
"network_ranges",
".",
"each",
"{",
"|",
"id",
",",
"subnet",
"|",
"matches",
"<<",
"id",
"if",
"subnet",
".",
"include?",
"(",
"ok_ip",
")",
"}",
"matches",
"end"
] |
def network_segments
Find the ids of the network segments that contain a given IP address.
Even tho IPAddr.include? will take a String or an IPAddr
I convert the ip to an IPAddr so that an exception will be raised if
the ip isn't a valid ip.
@param ip[String, IPAddr] the IP address to locate
@param refresh[Boolean] should the data be re-queried?
@return [Array<Integer>] the ids of the NetworkSegments containing the given ip
|
[
"def",
"network_segments",
"Find",
"the",
"ids",
"of",
"the",
"network",
"segments",
"that",
"contain",
"a",
"given",
"IP",
"address",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L899-L904
|
15,881
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.send_mobiledevice_mdm_command
|
def send_mobiledevice_mdm_command(targets, command, data = {})
JSS::MobileDevice.send_mdm_command(targets, command, opts: data, api: self)
end
|
ruby
|
def send_mobiledevice_mdm_command(targets, command, data = {})
JSS::MobileDevice.send_mdm_command(targets, command, opts: data, api: self)
end
|
[
"def",
"send_mobiledevice_mdm_command",
"(",
"targets",
",",
"command",
",",
"data",
"=",
"{",
"}",
")",
"JSS",
"::",
"MobileDevice",
".",
"send_mdm_command",
"(",
"targets",
",",
"command",
",",
"opts",
":",
"data",
",",
"api",
":",
"self",
")",
"end"
] |
Send an MDM command to one or more mobile devices managed by
this JSS
see {JSS::MobileDevice.send_mdm_command}
@deprecated Please use JSS::MobileDevice.send_mdm_command or its
convenience methods. @see JSS::MDM
|
[
"Send",
"an",
"MDM",
"command",
"to",
"one",
"or",
"more",
"mobile",
"devices",
"managed",
"by",
"this",
"JSS"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L922-L924
|
15,882
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.verify_basic_args
|
def verify_basic_args(args)
# must have server, user, and pw
raise JSS::MissingDataError, 'No JSS :server specified, or in configuration.' unless args[:server]
raise JSS::MissingDataError, 'No JSS :user specified, or in configuration.' unless args[:user]
raise JSS::MissingDataError, "Missing :pw for user '#{args[:user]}'" unless args[:pw]
end
|
ruby
|
def verify_basic_args(args)
# must have server, user, and pw
raise JSS::MissingDataError, 'No JSS :server specified, or in configuration.' unless args[:server]
raise JSS::MissingDataError, 'No JSS :user specified, or in configuration.' unless args[:user]
raise JSS::MissingDataError, "Missing :pw for user '#{args[:user]}'" unless args[:pw]
end
|
[
"def",
"verify_basic_args",
"(",
"args",
")",
"# must have server, user, and pw",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"'No JSS :server specified, or in configuration.'",
"unless",
"args",
"[",
":server",
"]",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"'No JSS :user specified, or in configuration.'",
"unless",
"args",
"[",
":user",
"]",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"\"Missing :pw for user '#{args[:user]}'\"",
"unless",
"args",
"[",
":pw",
"]",
"end"
] |
Raise execeptions if we don't have essential data for the connection
@param args[Hash] The args for #connect
@return [void]
|
[
"Raise",
"execeptions",
"if",
"we",
"don",
"t",
"have",
"essential",
"data",
"for",
"the",
"connection"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L1024-L1029
|
15,883
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.verify_server_version
|
def verify_server_version
@connected = true
# the jssuser resource is readable by anyone with a JSS acct
# regardless of their permissions.
# However, it's marked as 'deprecated'. Hopefully jamf will
# keep this basic level of info available for basic authentication
# and JSS version checking.
begin
@server = JSS::Server.new get_rsrc('jssuser')[:user], self
rescue RestClient::Unauthorized
raise JSS::AuthenticationError, "Incorrect JSS username or password for '#{@user}@#{@server_host}:#{@port}'."
end
min_vers = JSS.parse_jss_version(JSS::MINIMUM_SERVER_VERSION)[:version]
return if @server.version >= min_vers # we're good...
err_msg = "JSS version #{@server.raw_version} to low. Must be >= #{min_vers}"
@connected = false
raise JSS::UnsupportedError, err_msg
end
|
ruby
|
def verify_server_version
@connected = true
# the jssuser resource is readable by anyone with a JSS acct
# regardless of their permissions.
# However, it's marked as 'deprecated'. Hopefully jamf will
# keep this basic level of info available for basic authentication
# and JSS version checking.
begin
@server = JSS::Server.new get_rsrc('jssuser')[:user], self
rescue RestClient::Unauthorized
raise JSS::AuthenticationError, "Incorrect JSS username or password for '#{@user}@#{@server_host}:#{@port}'."
end
min_vers = JSS.parse_jss_version(JSS::MINIMUM_SERVER_VERSION)[:version]
return if @server.version >= min_vers # we're good...
err_msg = "JSS version #{@server.raw_version} to low. Must be >= #{min_vers}"
@connected = false
raise JSS::UnsupportedError, err_msg
end
|
[
"def",
"verify_server_version",
"@connected",
"=",
"true",
"# the jssuser resource is readable by anyone with a JSS acct",
"# regardless of their permissions.",
"# However, it's marked as 'deprecated'. Hopefully jamf will",
"# keep this basic level of info available for basic authentication",
"# and JSS version checking.",
"begin",
"@server",
"=",
"JSS",
"::",
"Server",
".",
"new",
"get_rsrc",
"(",
"'jssuser'",
")",
"[",
":user",
"]",
",",
"self",
"rescue",
"RestClient",
"::",
"Unauthorized",
"raise",
"JSS",
"::",
"AuthenticationError",
",",
"\"Incorrect JSS username or password for '#{@user}@#{@server_host}:#{@port}'.\"",
"end",
"min_vers",
"=",
"JSS",
".",
"parse_jss_version",
"(",
"JSS",
"::",
"MINIMUM_SERVER_VERSION",
")",
"[",
":version",
"]",
"return",
"if",
"@server",
".",
"version",
">=",
"min_vers",
"# we're good...",
"err_msg",
"=",
"\"JSS version #{@server.raw_version} to low. Must be >= #{min_vers}\"",
"@connected",
"=",
"false",
"raise",
"JSS",
"::",
"UnsupportedError",
",",
"err_msg",
"end"
] |
Verify that we can connect with the args provided, and that
the server version is high enough for this version of ruby-jss.
This makes the first API GET call and will raise an exception if things
are wrong, like failed authentication. Will also raise an exception
if the JSS version is too low
(see also JSS::Server)
@return [void]
|
[
"Verify",
"that",
"we",
"can",
"connect",
"with",
"the",
"args",
"provided",
"and",
"that",
"the",
"server",
"version",
"is",
"high",
"enough",
"for",
"this",
"version",
"of",
"ruby",
"-",
"jss",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L1041-L1061
|
15,884
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_connection.rb
|
JSS.APIConnection.build_rest_url
|
def build_rest_url(args)
@server_host = args[:server]
@port = args[:port].to_i
if args[:server_path]
# remove leading & trailing slashes in serverpath if any
@server_path = args[:server_path].sub %r{^/*(.*?)/*$}, Regexp.last_match(1)
# re-add single trailing slash
@server_path << '/'
end
# we're using ssl if:
# 1) args[:use_ssl] is anything but false
# or
# 2) the port is a known ssl port.
args[:use_ssl] = args[:use_ssl] != false || SSL_PORTS.include?(@port)
@protocol = 'http'
@protocol << 's' if args[:use_ssl]
# and here's the URL
"#{@protocol}://#{@server_host}:#{@port}/#{@server_path}#{RSRC_BASE}"
end
|
ruby
|
def build_rest_url(args)
@server_host = args[:server]
@port = args[:port].to_i
if args[:server_path]
# remove leading & trailing slashes in serverpath if any
@server_path = args[:server_path].sub %r{^/*(.*?)/*$}, Regexp.last_match(1)
# re-add single trailing slash
@server_path << '/'
end
# we're using ssl if:
# 1) args[:use_ssl] is anything but false
# or
# 2) the port is a known ssl port.
args[:use_ssl] = args[:use_ssl] != false || SSL_PORTS.include?(@port)
@protocol = 'http'
@protocol << 's' if args[:use_ssl]
# and here's the URL
"#{@protocol}://#{@server_host}:#{@port}/#{@server_path}#{RSRC_BASE}"
end
|
[
"def",
"build_rest_url",
"(",
"args",
")",
"@server_host",
"=",
"args",
"[",
":server",
"]",
"@port",
"=",
"args",
"[",
":port",
"]",
".",
"to_i",
"if",
"args",
"[",
":server_path",
"]",
"# remove leading & trailing slashes in serverpath if any",
"@server_path",
"=",
"args",
"[",
":server_path",
"]",
".",
"sub",
"%r{",
"}",
",",
"Regexp",
".",
"last_match",
"(",
"1",
")",
"# re-add single trailing slash",
"@server_path",
"<<",
"'/'",
"end",
"# we're using ssl if:",
"# 1) args[:use_ssl] is anything but false",
"# or",
"# 2) the port is a known ssl port.",
"args",
"[",
":use_ssl",
"]",
"=",
"args",
"[",
":use_ssl",
"]",
"!=",
"false",
"||",
"SSL_PORTS",
".",
"include?",
"(",
"@port",
")",
"@protocol",
"=",
"'http'",
"@protocol",
"<<",
"'s'",
"if",
"args",
"[",
":use_ssl",
"]",
"# and here's the URL",
"\"#{@protocol}://#{@server_host}:#{@port}/#{@server_path}#{RSRC_BASE}\"",
"end"
] |
Build the base URL for the API connection
@param args[Hash] The args for #connect
@return [String] The URI encoded URL
|
[
"Build",
"the",
"base",
"URL",
"for",
"the",
"API",
"connection"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L1069-L1090
|
15,885
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/sitable.rb
|
JSS.Sitable.site=
|
def site=(new_site)
return nil unless updatable? || creatable?
# unset the site? Use nil or an empty string
if NON_SITES.include? new_site
unset_site
return
end
new_id = JSS::Site.valid_id new_site, api: @api
new_name = JSS::Site.map_all_ids_to(:name, api: @api)[new_id]
# no change, go home.
return nil if new_name == @site_name
raise JSS::NoSuchItemError, "Site '#{new_site}' is not known to the JSS" unless new_id
@site_name = new_name
@site_id = new_id
@need_to_update = true
end
|
ruby
|
def site=(new_site)
return nil unless updatable? || creatable?
# unset the site? Use nil or an empty string
if NON_SITES.include? new_site
unset_site
return
end
new_id = JSS::Site.valid_id new_site, api: @api
new_name = JSS::Site.map_all_ids_to(:name, api: @api)[new_id]
# no change, go home.
return nil if new_name == @site_name
raise JSS::NoSuchItemError, "Site '#{new_site}' is not known to the JSS" unless new_id
@site_name = new_name
@site_id = new_id
@need_to_update = true
end
|
[
"def",
"site",
"=",
"(",
"new_site",
")",
"return",
"nil",
"unless",
"updatable?",
"||",
"creatable?",
"# unset the site? Use nil or an empty string",
"if",
"NON_SITES",
".",
"include?",
"new_site",
"unset_site",
"return",
"end",
"new_id",
"=",
"JSS",
"::",
"Site",
".",
"valid_id",
"new_site",
",",
"api",
":",
"@api",
"new_name",
"=",
"JSS",
"::",
"Site",
".",
"map_all_ids_to",
"(",
":name",
",",
"api",
":",
"@api",
")",
"[",
"new_id",
"]",
"# no change, go home.",
"return",
"nil",
"if",
"new_name",
"==",
"@site_name",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"Site '#{new_site}' is not known to the JSS\"",
"unless",
"new_id",
"@site_name",
"=",
"new_name",
"@site_id",
"=",
"new_id",
"@need_to_update",
"=",
"true",
"end"
] |
cat assigned?
Change the site of this object.
Any of the NON_SITES values will
unset the site
@param new_site[Integer, String] The new site
@return [void]
|
[
"cat",
"assigned?",
"Change",
"the",
"site",
"of",
"this",
"object",
".",
"Any",
"of",
"the",
"NON_SITES",
"values",
"will",
"unset",
"the",
"site"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/sitable.rb#L120-L139
|
15,886
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/sitable.rb
|
JSS.Sitable.parse_site
|
def parse_site
site_data =
if self.class::SITE_SUBSET == :top
@init_data[:site]
elsif @init_data[self.class::SITE_SUBSET]
@init_data[self.class::SITE_SUBSET][:site]
end
site_data ||= { name: NO_SITE_NAME, id: NO_SITE_ID }
@site_name = site_data[:name]
@site_id = site_data[:id]
end
|
ruby
|
def parse_site
site_data =
if self.class::SITE_SUBSET == :top
@init_data[:site]
elsif @init_data[self.class::SITE_SUBSET]
@init_data[self.class::SITE_SUBSET][:site]
end
site_data ||= { name: NO_SITE_NAME, id: NO_SITE_ID }
@site_name = site_data[:name]
@site_id = site_data[:id]
end
|
[
"def",
"parse_site",
"site_data",
"=",
"if",
"self",
".",
"class",
"::",
"SITE_SUBSET",
"==",
":top",
"@init_data",
"[",
":site",
"]",
"elsif",
"@init_data",
"[",
"self",
".",
"class",
"::",
"SITE_SUBSET",
"]",
"@init_data",
"[",
"self",
".",
"class",
"::",
"SITE_SUBSET",
"]",
"[",
":site",
"]",
"end",
"site_data",
"||=",
"{",
"name",
":",
"NO_SITE_NAME",
",",
"id",
":",
"NO_SITE_ID",
"}",
"@site_name",
"=",
"site_data",
"[",
":name",
"]",
"@site_id",
"=",
"site_data",
"[",
":id",
"]",
"end"
] |
Parse the site data from any incoming API data
@return [void]
|
[
"Parse",
"the",
"site",
"data",
"from",
"any",
"incoming",
"API",
"data"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/sitable.rb#L161-L172
|
15,887
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/sitable.rb
|
JSS.Sitable.add_site_to_xml
|
def add_site_to_xml(xmldoc)
root = xmldoc.root
site_elem =
if self.class::SITE_SUBSET == :top
root.add_element 'site'
else
parent_elem = root.elements[self.class::SITE_SUBSET.to_s]
parent_elem ||= root.add_element(self.class::SITE_SUBSET.to_s)
parent_elem.add_element 'site'
end
site_elem.add_element('name').text = site_name.to_s
end
|
ruby
|
def add_site_to_xml(xmldoc)
root = xmldoc.root
site_elem =
if self.class::SITE_SUBSET == :top
root.add_element 'site'
else
parent_elem = root.elements[self.class::SITE_SUBSET.to_s]
parent_elem ||= root.add_element(self.class::SITE_SUBSET.to_s)
parent_elem.add_element 'site'
end
site_elem.add_element('name').text = site_name.to_s
end
|
[
"def",
"add_site_to_xml",
"(",
"xmldoc",
")",
"root",
"=",
"xmldoc",
".",
"root",
"site_elem",
"=",
"if",
"self",
".",
"class",
"::",
"SITE_SUBSET",
"==",
":top",
"root",
".",
"add_element",
"'site'",
"else",
"parent_elem",
"=",
"root",
".",
"elements",
"[",
"self",
".",
"class",
"::",
"SITE_SUBSET",
".",
"to_s",
"]",
"parent_elem",
"||=",
"root",
".",
"add_element",
"(",
"self",
".",
"class",
"::",
"SITE_SUBSET",
".",
"to_s",
")",
"parent_elem",
".",
"add_element",
"'site'",
"end",
"site_elem",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"site_name",
".",
"to_s",
"end"
] |
parse site
Add the site to the XML for POSTing or PUTting to the API.
@param xmldoc[REXML::Document] The in-construction XML document
@return [void]
|
[
"parse",
"site",
"Add",
"the",
"site",
"to",
"the",
"XML",
"for",
"POSTing",
"or",
"PUTting",
"to",
"the",
"API",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/sitable.rb#L180-L191
|
15,888
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/peripheral.rb
|
JSS.Peripheral.associate
|
def associate(computer)
if computer =~ /^d+$/
raise JSS::NoSuchItemError, "No computer in the JSS with id #{computer}" unless JSS::Computer.all_ids(api: @api).include? computer
@computer_id = computer
else
raise JSS::NoSuchItemError, "No computer in the JSS with name #{computer}" unless JSS::Computer.all_names(api: @api).include? computer
@computer_id = JSS::Computer.map_all_ids_to(:name, api: @api).invert[computer]
end
@need_to_update = true
end
|
ruby
|
def associate(computer)
if computer =~ /^d+$/
raise JSS::NoSuchItemError, "No computer in the JSS with id #{computer}" unless JSS::Computer.all_ids(api: @api).include? computer
@computer_id = computer
else
raise JSS::NoSuchItemError, "No computer in the JSS with name #{computer}" unless JSS::Computer.all_names(api: @api).include? computer
@computer_id = JSS::Computer.map_all_ids_to(:name, api: @api).invert[computer]
end
@need_to_update = true
end
|
[
"def",
"associate",
"(",
"computer",
")",
"if",
"computer",
"=~",
"/",
"/",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No computer in the JSS with id #{computer}\"",
"unless",
"JSS",
"::",
"Computer",
".",
"all_ids",
"(",
"api",
":",
"@api",
")",
".",
"include?",
"computer",
"@computer_id",
"=",
"computer",
"else",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No computer in the JSS with name #{computer}\"",
"unless",
"JSS",
"::",
"Computer",
".",
"all_names",
"(",
"api",
":",
"@api",
")",
".",
"include?",
"computer",
"@computer_id",
"=",
"JSS",
"::",
"Computer",
".",
"map_all_ids_to",
"(",
":name",
",",
"api",
":",
"@api",
")",
".",
"invert",
"[",
"computer",
"]",
"end",
"@need_to_update",
"=",
"true",
"end"
] |
Associate this peripheral with a computer.
@param computer[String,Integer] the name or id of a computer in the JSS
@return [void]
|
[
"Associate",
"this",
"peripheral",
"with",
"a",
"computer",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/peripheral.rb#L233-L242
|
15,889
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/peripheral.rb
|
JSS.Peripheral.check_field
|
def check_field(field, value)
### get the field defs for this PeriphType, omitting the leading nil
@field_defs ||= JSS::PeripheralType.fetch(:name => @type, api: @api).fields.compact
### we must have the right number of fields, and they must have the same names
### as the definition
required_fields = @field_defs.map{|f| f[:name]}
raise JSS::InvalidDataError, "Peripherals of type '#{@type}' doesn't have a field '#{field}', they only have: #{required_fields.join(', ')}" unless required_fields.include? field
### any menu fields can only have values as defined by the type.
menu_flds = @field_defs.select{|f| f[:type] == "menu" }
menu_flds.each do |mf|
next unless mf[:name] == field
raise JSS::InvalidDataError, "The value for field '#{field}' must be one of: #{mf[:choices].join(', ')}" unless mf[:choices].include? value
end #if menu_flds.include? field
end
|
ruby
|
def check_field(field, value)
### get the field defs for this PeriphType, omitting the leading nil
@field_defs ||= JSS::PeripheralType.fetch(:name => @type, api: @api).fields.compact
### we must have the right number of fields, and they must have the same names
### as the definition
required_fields = @field_defs.map{|f| f[:name]}
raise JSS::InvalidDataError, "Peripherals of type '#{@type}' doesn't have a field '#{field}', they only have: #{required_fields.join(', ')}" unless required_fields.include? field
### any menu fields can only have values as defined by the type.
menu_flds = @field_defs.select{|f| f[:type] == "menu" }
menu_flds.each do |mf|
next unless mf[:name] == field
raise JSS::InvalidDataError, "The value for field '#{field}' must be one of: #{mf[:choices].join(', ')}" unless mf[:choices].include? value
end #if menu_flds.include? field
end
|
[
"def",
"check_field",
"(",
"field",
",",
"value",
")",
"### get the field defs for this PeriphType, omitting the leading nil",
"@field_defs",
"||=",
"JSS",
"::",
"PeripheralType",
".",
"fetch",
"(",
":name",
"=>",
"@type",
",",
"api",
":",
"@api",
")",
".",
"fields",
".",
"compact",
"### we must have the right number of fields, and they must have the same names",
"### as the definition",
"required_fields",
"=",
"@field_defs",
".",
"map",
"{",
"|",
"f",
"|",
"f",
"[",
":name",
"]",
"}",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"Peripherals of type '#{@type}' doesn't have a field '#{field}', they only have: #{required_fields.join(', ')}\"",
"unless",
"required_fields",
".",
"include?",
"field",
"### any menu fields can only have values as defined by the type.",
"menu_flds",
"=",
"@field_defs",
".",
"select",
"{",
"|",
"f",
"|",
"f",
"[",
":type",
"]",
"==",
"\"menu\"",
"}",
"menu_flds",
".",
"each",
"do",
"|",
"mf",
"|",
"next",
"unless",
"mf",
"[",
":name",
"]",
"==",
"field",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"The value for field '#{field}' must be one of: #{mf[:choices].join(', ')}\"",
"unless",
"mf",
"[",
":choices",
"]",
".",
"include?",
"value",
"end",
"#if menu_flds.include? field",
"end"
] |
check a field, the field name must match those defined in
the appropriate peripheral type.
If a field is a menu field, the value must also be one of those defined
in the periph type.
Raise an exception if wrong.
|
[
"check",
"a",
"field",
"the",
"field",
"name",
"must",
"match",
"those",
"defined",
"in",
"the",
"appropriate",
"peripheral",
"type",
".",
"If",
"a",
"field",
"is",
"a",
"menu",
"field",
"the",
"value",
"must",
"also",
"be",
"one",
"of",
"those",
"defined",
"in",
"the",
"periph",
"type",
".",
"Raise",
"an",
"exception",
"if",
"wrong",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/peripheral.rb#L270-L286
|
15,890
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/patch_policy.rb
|
JSS.PatchPolicy.validate_patch_title
|
def validate_patch_title(a_title)
if a_title.is_a? JSS::PatchTitle
@patch_title = a_title
return a_title.id
end
raise JSS::MissingDataError, ':patch_title is required' unless a_title
title_id = JSS::PatchTitle.valid_id a_title
return title_id if title_id
raise JSS::NoSuchItemError, "No Patch Title matches '#{a_title}'"
end
|
ruby
|
def validate_patch_title(a_title)
if a_title.is_a? JSS::PatchTitle
@patch_title = a_title
return a_title.id
end
raise JSS::MissingDataError, ':patch_title is required' unless a_title
title_id = JSS::PatchTitle.valid_id a_title
return title_id if title_id
raise JSS::NoSuchItemError, "No Patch Title matches '#{a_title}'"
end
|
[
"def",
"validate_patch_title",
"(",
"a_title",
")",
"if",
"a_title",
".",
"is_a?",
"JSS",
"::",
"PatchTitle",
"@patch_title",
"=",
"a_title",
"return",
"a_title",
".",
"id",
"end",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"':patch_title is required'",
"unless",
"a_title",
"title_id",
"=",
"JSS",
"::",
"PatchTitle",
".",
"valid_id",
"a_title",
"return",
"title_id",
"if",
"title_id",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No Patch Title matches '#{a_title}'\"",
"end"
] |
raise an error if the patch title we're trying to use isn't available in
the jss. If handed a PatchTitle instance, we assume it came from the JSS
@param new_title[String,Integer,JSS::PatchTitle] the title to validate
@return [Integer] the id of the valid title
|
[
"raise",
"an",
"error",
"if",
"the",
"patch",
"title",
"we",
"re",
"trying",
"to",
"use",
"isn",
"t",
"available",
"in",
"the",
"jss",
".",
"If",
"handed",
"a",
"PatchTitle",
"instance",
"we",
"assume",
"it",
"came",
"from",
"the",
"JSS"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_policy.rb#L543-L552
|
15,891
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/patch_policy.rb
|
JSS.PatchPolicy.validate_target_version
|
def validate_target_version(tgt_vers)
raise JSS::MissingDataError, "target_version can't be nil" unless tgt_vers
JSS::Validate.non_empty_string tgt_vers
unless patch_title(:refresh).versions.key? tgt_vers
errmsg = "Version '#{tgt_vers}' does not exist for title: #{patch_title_name}."
raise JSS::NoSuchItemError, errmsg
end
return tgt_vers if patch_title.versions_with_packages.key? tgt_vers
errmsg = "Version '#{tgt_vers}' cannot be used in Patch Policies until a package is assigned to it."
raise JSS::UnsupportedError, errmsg
end
|
ruby
|
def validate_target_version(tgt_vers)
raise JSS::MissingDataError, "target_version can't be nil" unless tgt_vers
JSS::Validate.non_empty_string tgt_vers
unless patch_title(:refresh).versions.key? tgt_vers
errmsg = "Version '#{tgt_vers}' does not exist for title: #{patch_title_name}."
raise JSS::NoSuchItemError, errmsg
end
return tgt_vers if patch_title.versions_with_packages.key? tgt_vers
errmsg = "Version '#{tgt_vers}' cannot be used in Patch Policies until a package is assigned to it."
raise JSS::UnsupportedError, errmsg
end
|
[
"def",
"validate_target_version",
"(",
"tgt_vers",
")",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"\"target_version can't be nil\"",
"unless",
"tgt_vers",
"JSS",
"::",
"Validate",
".",
"non_empty_string",
"tgt_vers",
"unless",
"patch_title",
"(",
":refresh",
")",
".",
"versions",
".",
"key?",
"tgt_vers",
"errmsg",
"=",
"\"Version '#{tgt_vers}' does not exist for title: #{patch_title_name}.\"",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"errmsg",
"end",
"return",
"tgt_vers",
"if",
"patch_title",
".",
"versions_with_packages",
".",
"key?",
"tgt_vers",
"errmsg",
"=",
"\"Version '#{tgt_vers}' cannot be used in Patch Policies until a package is assigned to it.\"",
"raise",
"JSS",
"::",
"UnsupportedError",
",",
"errmsg",
"end"
] |
raise an exception if a given target version is not valid for this policy
Otherwise return it
|
[
"raise",
"an",
"exception",
"if",
"a",
"given",
"target",
"version",
"is",
"not",
"valid",
"for",
"this",
"policy",
"Otherwise",
"return",
"it"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_policy.rb#L557-L571
|
15,892
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/patch_policy.rb
|
JSS.PatchPolicy.refetch_version_info
|
def refetch_version_info
tmp = self.class.fetch id: id
@release_date = tmp.release_date
@incremental_update = tmp.incremental_update
@reboot = tmp.reboot
@minimum_os = tmp.minimum_os
@kill_apps = tmp.kill_apps
end
|
ruby
|
def refetch_version_info
tmp = self.class.fetch id: id
@release_date = tmp.release_date
@incremental_update = tmp.incremental_update
@reboot = tmp.reboot
@minimum_os = tmp.minimum_os
@kill_apps = tmp.kill_apps
end
|
[
"def",
"refetch_version_info",
"tmp",
"=",
"self",
".",
"class",
".",
"fetch",
"id",
":",
"id",
"@release_date",
"=",
"tmp",
".",
"release_date",
"@incremental_update",
"=",
"tmp",
".",
"incremental_update",
"@reboot",
"=",
"tmp",
".",
"reboot",
"@minimum_os",
"=",
"tmp",
".",
"minimum_os",
"@kill_apps",
"=",
"tmp",
".",
"kill_apps",
"end"
] |
Update our local version data after the target_version is changed
|
[
"Update",
"our",
"local",
"version",
"data",
"after",
"the",
"target_version",
"is",
"changed"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_policy.rb#L579-L586
|
15,893
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/user.rb
|
JSS.User.add_site
|
def add_site (site)
return nil if @sites.map{|s| s[:name]}.include? site
raise JSS::InvalidDataError, "No site in the JSS named #{site}" unless JSS::Site.all_names(api: @api).include? site
@sites << {:name => site}
@need_to_update = true
end
|
ruby
|
def add_site (site)
return nil if @sites.map{|s| s[:name]}.include? site
raise JSS::InvalidDataError, "No site in the JSS named #{site}" unless JSS::Site.all_names(api: @api).include? site
@sites << {:name => site}
@need_to_update = true
end
|
[
"def",
"add_site",
"(",
"site",
")",
"return",
"nil",
"if",
"@sites",
".",
"map",
"{",
"|",
"s",
"|",
"s",
"[",
":name",
"]",
"}",
".",
"include?",
"site",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"No site in the JSS named #{site}\"",
"unless",
"JSS",
"::",
"Site",
".",
"all_names",
"(",
"api",
":",
"@api",
")",
".",
"include?",
"site",
"@sites",
"<<",
"{",
":name",
"=>",
"site",
"}",
"@need_to_update",
"=",
"true",
"end"
] |
Add this user to a site
@param site[String] the name of the site
@return [void]
|
[
"Add",
"this",
"user",
"to",
"a",
"site"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/user.rb#L233-L238
|
15,894
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/user.rb
|
JSS.User.remove_site
|
def remove_site (site)
return nil unless @sites.map{|s| s[:name]}.include? site
@sites.reject!{|s| s[:name] == site}
@need_to_update = true
end
|
ruby
|
def remove_site (site)
return nil unless @sites.map{|s| s[:name]}.include? site
@sites.reject!{|s| s[:name] == site}
@need_to_update = true
end
|
[
"def",
"remove_site",
"(",
"site",
")",
"return",
"nil",
"unless",
"@sites",
".",
"map",
"{",
"|",
"s",
"|",
"s",
"[",
":name",
"]",
"}",
".",
"include?",
"site",
"@sites",
".",
"reject!",
"{",
"|",
"s",
"|",
"s",
"[",
":name",
"]",
"==",
"site",
"}",
"@need_to_update",
"=",
"true",
"end"
] |
Remove this user from a site
@param site[String] the name of the site
@return [void]
|
[
"Remove",
"this",
"user",
"from",
"a",
"site"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/user.rb#L247-L251
|
15,895
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/network_segment.rb
|
JSS.NetworkSegment.overlap?
|
def overlap?(other_segment)
raise TypeError, 'Argument must be a JSS::NetworkSegment' unless \
other_segment.is_a? JSS::NetworkSegment
other_range = other_segment.range
range.include?(other_range.begin) || range.include?(other_range.end)
end
|
ruby
|
def overlap?(other_segment)
raise TypeError, 'Argument must be a JSS::NetworkSegment' unless \
other_segment.is_a? JSS::NetworkSegment
other_range = other_segment.range
range.include?(other_range.begin) || range.include?(other_range.end)
end
|
[
"def",
"overlap?",
"(",
"other_segment",
")",
"raise",
"TypeError",
",",
"'Argument must be a JSS::NetworkSegment'",
"unless",
"other_segment",
".",
"is_a?",
"JSS",
"::",
"NetworkSegment",
"other_range",
"=",
"other_segment",
".",
"range",
"range",
".",
"include?",
"(",
"other_range",
".",
"begin",
")",
"||",
"range",
".",
"include?",
"(",
"other_range",
".",
"end",
")",
"end"
] |
Does this network segment overlap with another?
@param other_segment[JSS::NetworkSegment] the other segment to check
@return [Boolean] Does the other segment overlap this one?
|
[
"Does",
"this",
"network",
"segment",
"overlap",
"with",
"another?"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L304-L309
|
15,896
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/network_segment.rb
|
JSS.NetworkSegment.include?
|
def include?(thing)
if thing.is_a? JSS::NetworkSegment
@starting_address <= thing.range.begin && @ending_address >= thing.range.end
else
thing = IPAddr.new thing.to_s
range.include? thing
end
end
|
ruby
|
def include?(thing)
if thing.is_a? JSS::NetworkSegment
@starting_address <= thing.range.begin && @ending_address >= thing.range.end
else
thing = IPAddr.new thing.to_s
range.include? thing
end
end
|
[
"def",
"include?",
"(",
"thing",
")",
"if",
"thing",
".",
"is_a?",
"JSS",
"::",
"NetworkSegment",
"@starting_address",
"<=",
"thing",
".",
"range",
".",
"begin",
"&&",
"@ending_address",
">=",
"thing",
".",
"range",
".",
"end",
"else",
"thing",
"=",
"IPAddr",
".",
"new",
"thing",
".",
"to_s",
"range",
".",
"include?",
"thing",
"end",
"end"
] |
Does this network segment include an address or another segment?
Inclusion means the other is completely inside this one.
@param thing[JSS::NetworkSegment, String, IPAddr] the other thing to check
@return [Boolean] Does this segment include the other?
|
[
"Does",
"this",
"network",
"segment",
"include",
"an",
"address",
"or",
"another",
"segment?",
"Inclusion",
"means",
"the",
"other",
"is",
"completely",
"inside",
"this",
"one",
"."
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L318-L325
|
15,897
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/network_segment.rb
|
JSS.NetworkSegment.building=
|
def building=(newval)
new = JSS::Building.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No building matching '#{newval}'" unless new
@building = new[:name]
@need_to_update = true
end
|
ruby
|
def building=(newval)
new = JSS::Building.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No building matching '#{newval}'" unless new
@building = new[:name]
@need_to_update = true
end
|
[
"def",
"building",
"=",
"(",
"newval",
")",
"new",
"=",
"JSS",
"::",
"Building",
".",
"all",
".",
"select",
"{",
"|",
"b",
"|",
"(",
"b",
"[",
":id",
"]",
"==",
"newval",
")",
"||",
"(",
"b",
"[",
":name",
"]",
"==",
"newval",
")",
"}",
"[",
"0",
"]",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"\"No building matching '#{newval}'\"",
"unless",
"new",
"@building",
"=",
"new",
"[",
":name",
"]",
"@need_to_update",
"=",
"true",
"end"
] |
Does this network segment equal another?
equality means the ranges are equal
@param other_segment[JSS::NetworkSegment] the other segment to check
@return [Boolean] Does this segment include the other?
Set the building
@param newval[String, Integer] the new building by name or id, must be in the JSS
@return [void]
|
[
"Does",
"this",
"network",
"segment",
"equal",
"another?",
"equality",
"means",
"the",
"ranges",
"are",
"equal"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L346-L351
|
15,898
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/network_segment.rb
|
JSS.NetworkSegment.override_buildings=
|
def override_buildings=(newval)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? newval
@override_buildings = newval
@need_to_update = true
end
|
ruby
|
def override_buildings=(newval)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? newval
@override_buildings = newval
@need_to_update = true
end
|
[
"def",
"override_buildings",
"=",
"(",
"newval",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be boolean true or false'",
"unless",
"JSS",
"::",
"TRUE_FALSE",
".",
"include?",
"newval",
"@override_buildings",
"=",
"newval",
"@need_to_update",
"=",
"true",
"end"
] |
set the override buildings option
@param newval[Boolean] the new override buildings option
@return [void]
|
[
"set",
"the",
"override",
"buildings",
"option"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L359-L363
|
15,899
|
PixarAnimationStudios/ruby-jss
|
lib/jss/api_object/network_segment.rb
|
JSS.NetworkSegment.department=
|
def department=(newval)
new = JSS::Department.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No department matching '#{newval}' in the JSS" unless new
@department = new[:name]
@need_to_update = true
end
|
ruby
|
def department=(newval)
new = JSS::Department.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No department matching '#{newval}' in the JSS" unless new
@department = new[:name]
@need_to_update = true
end
|
[
"def",
"department",
"=",
"(",
"newval",
")",
"new",
"=",
"JSS",
"::",
"Department",
".",
"all",
".",
"select",
"{",
"|",
"b",
"|",
"(",
"b",
"[",
":id",
"]",
"==",
"newval",
")",
"||",
"(",
"b",
"[",
":name",
"]",
"==",
"newval",
")",
"}",
"[",
"0",
"]",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"\"No department matching '#{newval}' in the JSS\"",
"unless",
"new",
"@department",
"=",
"new",
"[",
":name",
"]",
"@need_to_update",
"=",
"true",
"end"
] |
set the department
@param newval[String, Integer] the new dept by name or id, must be in the JSS
@return [void]
|
[
"set",
"the",
"department"
] |
4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9
|
https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L371-L376
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.