On Monday, February 25, 2019 at 2:30:02 AM UTC-6, Dirk Heinrichs wrote: > > Am Montag, den 25.02.2019, 09:10 +0100 schrieb Martin Alfke: > > Within the provider you specify getters (how to read existing data) and > setters (how to set new data). > Maybe you want to have a look at my PuppetConf talk "Moving from exec to > types and providers". You can find it at Puppet youtube channel. > There I describe getters and setters. > > > Thanks a lot. I think I've already understood that part. The problem I > have is how to implement points 1 and 3 (getting the current configuration > and writing back the changes). What are the entry points for these? If a > type is ensurable I have "exists?", "create" and "destroy", but what do I > use if it's not? > > If the complete set of instances is well known, or if the API provides a way to enumerate instances, then your provider should be able to implement prefetching <https://puppet.com/docs/puppet/5.5/provider_development.html#prefetching>. It can in any case implement flushing <https://puppet.com/docs/puppet/5.5/provider_development.html#flushing>. These can serve as the entry points you're looking for. If you can't or don't want to use one or both of these, then the alternative entry points are the property getter and setter methods, respectively.
It sounds like your API deals with state in whole-object units. That's a classic case for implementing flushing. It plays well with prefetching, too, but if you cannot enumerate instances or otherwise don't want to prefetch, then your provider can still implement its own, custom support for as-needed state fetching, and it can make all the property getters hook that. For example, you could have methods is_fetched?() and fetch(), and begin each property (not parameter) getter with fetch unless is_fetched? Do understand that these method names are not special. Puppet offers no built-in hooks for these particular operations. You can implement something analogous on the setter side, but unless you have a way to modify properties individually, I don't see a reason to prefer that over flushing. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/8a45baf5-ed10-4abd-88e8-f83cbfa0b856%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.