ninech / netbox-client-ruby

A ruby client library for Netbox v2.
MIT License
24 stars 21 forks source link

Add find_by method for Entities class #21

Closed born4new closed 6 years ago

born4new commented 6 years ago

What's new?

🎉 New find_by method for Entities 🎉

Example

# Suppose the following data is present in the API: 
# 
# DeviceType(model_name: 'chassis-old', height: 2)
# DeviceType(model_name: 'chassis-new', height: 1)

NetboxClientRuby.dcim.device_types.find_by(model_name: 'chassis')
# => nil

NetboxClientRuby.dcim.device_types.find_by(model_name: 'chassis-old')
# => DeviceType(model_name: 'chassis-old', height: 2)

NetboxClientRuby.dcim.device_types.find_by(model_name: 'chassis-old', height: 1)
# => nil

NetboxClientRuby.dcim.device_types.find_by(model_name: 'chassis-new', height: 1)
# => DeviceType(model_name: 'chassis-new', height: 1)