README-2.0.0.md in ruby-jss-2.0.0rc1 vs README-2.0.0.md in ruby-jss-2.0.0

- old
+ new

@@ -29,10 +29,11 @@ - [Paged queries to the Jamf Pro API](#paged-queries-to-the-jamf-pro-api) - [API data are no longer cached ?](#api-data-are-no-longer-cached-) - [No Attribute aliases for Jamf Pro API objects](#no-attribute-aliases-for-jamf-pro-api-objects) - [Class/Mixin hierarchy for Jamf Pro API objects](#classmixin-hierarchy-for-jamf-pro-api-objects) - [Support for 'Sticky Sessions' in Jamf Cloud](#support-for-sticky-sessions-in-jamf-cloud) + - [The valid_id method for Classic API collection classes](#the-valid_id-method-for-classic-api-collection-classes) - [Planned deprecations](#planned-deprecations) - [Use of the term 'api'](#use-of-the-term-api) - [.map_all_ids_to method for Classic API collection classes](#map_all_ids_to-method-for-classic-api-collection-classes) - [Using .make, #create, and #update for Classic API objects](#using-make-create-and-update-for-classic-api-objects) - [JSS::CONFIG](#jssconfig) @@ -154,10 +155,13 @@ - See [No Attribute aliases for Jamf Pro API objects](#no-attribute-aliases-for-jamf-pro-api-objects) below - Subclassing ruby-jss classes in your own code. - Those classes, and methods called on them, may need to be updated to match the new ruby-jss classes, in order to maintain _their_ backward compatibility. +- If you make calls to Classic API's `.valid_id` class method for collection classes, and you pass in an integer as a String, e.g. '1234', expecting to get the valid id of the object with the _name_ or _serial_number_ '1234' you will now get back the id 1234 if there is an object with that id. That may not be the id of the object you were looking for. + - See [The valid_id method for Classic API collection classes](#the-valid_id-method-for-classic-api-collection-classes) below for details and how to do such a validation now. + ## Notable changes from ruby-jss 1.x ### Paged queries to the Jamf Pro API In the previous Jamf module, to get paged API results from a list of all objects in a collection, you would use the `page_size:` and `page:` parameters to the `.all` class method, and then use `.next_page_of_all` to get subsequent pages. Unfortunately the way this happened was not threadsafe. @@ -210,9 +214,46 @@ Attempting to enable a sticky session with a connection to an on-prem server (host not ending in 'jamfcloud.com') will raise an error. For details about Sticky Sessions see [Sticky Sessions for Jamf Cloud](https://developer.jamf.com/developer-guide/docs/sticky-sessions-for-jamf-cloud) at the Jamf Developer site. **WARNING:** Jamf recommends NOT using sticky sessions unless they are needed. Using them inappropriately may negatively impact performance, especially for large automated processes. + +### The `valid_id` method for Classic API collection classes + +In the Classic API, object ids are Integers, but in the Jamf Pro API, they are Strings containing integers. + +In previous versions of ruby-jss, the `valid_id` class method for the Jamf Pro API will accept Integers and convert them to Strings to search for the valid id. In order to provide the same flexibility, `valid_id` now works the same way for regardless of which API is used. + +Previously, the Classic API collection classes would return nil (no match) if you passed in an id as a string, unless you had an object with a name or other identifier with that numeric string value. + +So for example, assuming you wanted to find out if the id 1234 was valid, you could do + +```ruby +ok_id = JSS::Computer.valid_id 1234 +# => 1234, or nil if 1234 is not a valid id +``` + +But if you did + +```ruby +ok_id = JSS::Computer.valid_id '1234' +# => nil, or the id of a computer _named_ '1234' +# (no computer would have '1234' as a serialnumber, udid, or macaddress) +``` +you would likely not get the integer id 1234 back. + +In ruby-jss 2.0.0, the valid_id method has changed so that the second example above will return the integer id 1234, if it exists as an id. If not, it will look at other identifiers with the string value, and return the id of any match, or nil if there's no match. + +The downside of this is: what if you really _are_ looking for the id of the object with the name '1234'? + +To deal with that situation, the valid_id method for the Classic API now behaves like the one for the Jamf Pro API: it can accept an arbitrary key: value pair, limiting the search to the indentifier used as the key. + +So you can use this to get what you're looking for + +```ruby +ok_id = JSS::Computer.valid_id name: '1234' +# => nil, or the id of a computer named '1234' +``` ## Planned deprecations Even though it was publically released in 2014, ruby-jss's origins are from 2009, so it's been around for a while. We've learned a lot since then, and lots of the old lingering code is terribly out of date.