Class: Jamf::Printer

Inherits:
APIObject show all
Includes:
Categorizable, Creatable, Updatable
Defined in:
lib/jamf/api/classic/api_objects/printer.rb

Overview

Printer object inside JSS

See Also:

Constant Summary collapse

RSRC_BASE =

The base for REST resources of this class

'printers'.freeze
RSRC_LIST_KEY =

the hash key used for the JSON list output of all objects in the JSS

:printers
RSRC_OBJECT_KEY =

The hash key used for the JSON object output It’s also used in various error messages

:printer
CATEGORY_SUBSET =

Where is the Category in the API JSON?

:top
CATEGORY_DATA_TYPE =

How is the category stored in the API data?

String

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Printer

Returns a new instance of Printer.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 89

def initialize(**args)
    super

    if self.in_jss?

        @uri = @init_data[:uri]
        @CUPS_name = @init_data[:CUPS_name]
        @location = @init_data[:location]
        @model = @init_data[:model]
        @shared = @init_data[:shared]
        @info = @init_data[:info]
        @notes = @init_data[:notes]
        @make_default = @init_data[:make_default]
        @use_generic = @init_data[:use_generic]
        @ppd = @init_data[:ppd]
        @ppd_contents = @init_data[:ppd_contents]
        @ppd_path = @init_data[:ppd_path]
        @os_requirements = @init_data[:os_requirements]
    else

        raise Jamf::MissingDataError, "CUPS_name must be provided." unless !@init_data[:CUPS_name].nil?
        raise Jamf::MissingDataError, "uri must be provided." unless !@init_data[:uri].nil?

        raise Jamf::InvalidDataError, "uri must be a String." unless @init_data[:uri].is_a?(String) || @init_data[:uri].nil?
        raise Jamf::InvalidDataError, "CUPS_name must be a String." unless @init_data[:CUPS_name].is_a?(String)
        raise Jamf::InvalidDataError, "location must be a String." unless @init_data[:location].is_a?(String) || @init_data[:location].nil?
        raise Jamf::InvalidDataError, "model must be a String." unless @init_data[:model].is_a?(String) || @init_data[:model].nil?
        raise Jamf::InvalidDataError, "info must be a String." unless @init_data[:info].is_a?(String) || @init_data[:info].nil?
        raise Jamf::InvalidDataError, "notes must be a String." unless @init_data[:notes].is_a?(String) || @init_data[:notes].nil?
        raise Jamf::InvalidDataError, "ppd must be a String." unless @init_data[:ppd].is_a?(String) || @init_data[:ppd].nil?
        raise Jamf::InvalidDataError, "ppd_contents must be a String." unless @init_data[:ppd_contents].is_a?(String) || @init_data[:ppd_contents].nil?
        raise Jamf::InvalidDataError, "ppd_path must be a String." unless @init_data[:ppd_path].is_a?(String) || @init_data[:ppd_path].nil?
        raise Jamf::InvalidDataError, "os_requirements must be a String." unless @init_data[:os_requirements].is_a?(String) || @init_data[:os_requirements].nil?
        raise Jamf::InvalidDataError, "shared must be a String." unless (@init_data[:shared].is_a?(TrueClass) || @init_data[:shared].is_a?(FalseClass)) || @init_data[:shared].nil?
        raise Jamf::InvalidDataError, "make_default must be a String." unless (@init_data[:make_default].is_a?(TrueClass) || @init_data[:make_default].is_a?(FalseClass)) || @init_data[:make_default].nil?
        raise Jamf::InvalidDataError, "use_generic must be a String." unless (@init_data[:use_generic].is_a?(TrueClass) || @init_data[:use_generic].is_a?(FalseClass)) || @init_data[:use_generic].nil?

        @uri = @init_data[:uri]
        @CUPS_name = @init_data[:CUPS_name]
        @location = @init_data[:location]
        @model = @init_data[:model]
        @shared = @init_data[:shared]
        @info = @init_data[:info]
        @notes = @init_data[:notes]
        @make_default = @init_data[:make_default]
        @use_generic = @init_data[:use_generic]
        @ppd = @init_data[:ppd]
        @ppd_contents = @init_data[:ppd_contents]
        @ppd_path = @init_data[:ppd_path]
        @os_requirements = @init_data[:os_requirements]
    end
end

Instance Attribute Details

#CUPS_nameString

Returns The CUPs name to be used.

Returns:

  • (String)

    The CUPs name to be used



50
51
52
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 50

def CUPS_name
  @CUPS_name
end

#infoString

Returns Information for this specific printer.

Returns:

  • (String)

    Information for this specific printer.



62
63
64
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 62

def info
  @info
end

#locationString

Returns The physical location of the printer.

Returns:

  • (String)

    The physical location of the printer.



53
54
55
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 53

def location
  @location
end

#make_defaultBoolean

Returns Make this printer as the default printer upon installation.

Returns:

  • (Boolean)

    Make this printer as the default printer upon installation.



68
69
70
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 68

def make_default
  @make_default
end

#modelString

Returns The specific model of printer.

Returns:

  • (String)

    The specific model of printer.



56
57
58
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 56

def model
  @model
end

#need_to_updateBoolean (readonly) Originally defined in module Updatable

Returns do we have unsaved changes?.

Returns:

  • (Boolean)

    do we have unsaved changes?

#notesString

Returns Notes for this specific printer.

Returns:

  • (String)

    Notes for this specific printer.



65
66
67
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 65

def notes
  @notes
end

#os_requirementsString

Returns The OS version requirements seperated by commas.

Returns:

  • (String)

    The OS version requirements seperated by commas



83
84
85
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 83

def os_requirements
  @os_requirements
end

#ppdString

Returns The PPD file name.

Returns:

  • (String)

    The PPD file name.



74
75
76
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 74

def ppd
  @ppd
end

#ppd_contentsString

Returns The contents of the PPD file.

Returns:

  • (String)

    The contents of the PPD file.



77
78
79
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 77

def ppd_contents
  @ppd_contents
end

#ppd_pathString

Returns The path the PPD file will be installed.

Returns:

  • (String)

    The path the PPD file will be installed.



80
81
82
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 80

def ppd_path
  @ppd_path
end

#sharedBoolean

Returns Is this printer to be shared?.

Returns:

  • (Boolean)

    Is this printer to be shared?



59
60
61
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 59

def shared
  @shared
end

#uriString

Returns The URI path for the specific printer.

Returns:

  • (String)

    The URI path for the specific printer.



47
48
49
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 47

def uri
  @uri
end

#use_genericBoolean

Returns Use a generic PPD.

Returns:

  • (Boolean)

    Use a generic PPD.



71
72
73
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 71

def use_generic
  @use_generic
end

Instance Method Details

#category=(new_cat) ⇒ void Originally defined in module Categorizable

This method returns an undefined value.

Change the category of this object. Any of the NON_CATEGORIES values will unset the category

Parameters:

  • new_cat (Integer, String)

    The new category

Raises:

#category_assigned?Boolean Also known as: categorized? Originally defined in module Categorizable

Does this object have a category assigned?

Returns:

  • (Boolean)

    Does this object have a category assigned?

#category_idInteger Originally defined in module Categorizable

The id of the category for this object.

Returns:

  • (Integer)

    The id of the category for this object.

#category_nameString Also known as: category Originally defined in module Categorizable

The name of the category for this object. For backward compatibility, this is aliased to just ‘category’

Returns:

  • (String)

    The name of the category for this object.

#category_objectJamf::Category Originally defined in module Categorizable

The Jamf::Category instance for this object’s category

Returns:

  • (Jamf::Category)

    The Jamf::Category instance for this object’s category

#clone(new_name, api: nil, cnx: nil) ⇒ APIObject Originally defined in module Creatable

make a clone of this API object, with a new name. The class must be creatable

Parameters:

  • name (String)

    the name for the new object

  • cnx (Jamf::Connection) (defaults to: nil)

    the API in which to create the object Defaults to the API used to instantiate this object

Returns:

  • (APIObject)

    An unsaved clone of this APIObject with the given name

Raises:

#evaluate_new_category(new_cat) ⇒ Array<String, Integer> Originally defined in module Categorizable

Given a category name or id, return the name and id TODO: use APIObject.exist? and/or APIObject.valid_id

Parameters:

  • new_cat (String, Integer)

    The name or id of a possible category

Returns:

  • (Array<String, Integer>)

    The matching name and id, which may be nil.

#name=(newname) ⇒ void Originally defined in module Updatable

This method returns an undefined value.

Change the name of this item Remember to #update to push changes to the server.

Parameters:

  • newname (String)

    the new name

Raises:

#pretty_print_instance_variablesArray

Remove the various large data from the instance_variables used to create pretty-print (pp) output.

Returns:

  • (Array)

    the desired instance_variables



408
409
410
411
412
# File 'lib/jamf/api/classic/api_objects/printer.rb', line 408

def pretty_print_instance_variables
  vars = super
  vars.delete :@ppd_contents
  vars
end

#unset_categoryvoid Originally defined in module Categorizable

This method returns an undefined value.

Set the category to nothing