@@ -251,7 +251,14 @@ class Resource(object):
251251 #: Use PUT for create operations on this resource.
252252 put_create = False
253253
254- def __init__ (self , synchronized = False , ** attrs ):
254+ def __init__ (self , _synchronized = False , ** attrs ):
255+ """The base resource
256+
257+ :param bool _synchronized: This is not intended to be used directly.
258+ See :meth:`~openstack.resource2.Resource.new` and
259+ :meth:`~openstack.resource2.Resource.existing`.
260+ """
261+
255262 # NOTE: _collect_attrs modifies **attrs in place, removing
256263 # items as they match up with any of the body, header,
257264 # or uri mappings.
@@ -261,11 +268,11 @@ def __init__(self, synchronized=False, **attrs):
261268 # How strict should we be here? Should strict be an option?
262269
263270 self ._body = _ComponentManager (attributes = body ,
264- synchronized = synchronized )
271+ synchronized = _synchronized )
265272 self ._header = _ComponentManager (attributes = header ,
266- synchronized = synchronized )
273+ synchronized = _synchronized )
267274 self ._uri = _ComponentManager (attributes = uri ,
268- synchronized = synchronized )
275+ synchronized = _synchronized )
269276
270277 def __repr__ (self ):
271278 pairs = ["%s=%s" % (k , v ) for k , v in dict (itertools .chain (
@@ -418,24 +425,32 @@ def _get_id(value):
418425 def new (cls , ** kwargs ):
419426 """Create a new instance of this resource.
420427
421- Internally set flags such that it is marked as not present on the
422- server.
428+ When creating the instance set the ``_synchronized`` parameter
429+ of :class:`Resource` to ``False`` to indicate that the resource does
430+ not yet exist on the server side. This marks all attributes passed
431+ in ``**kwargs`` as "dirty" on the resource, and thusly tracked
432+ as necessary in subsequent calls such as :meth:`update`.
423433
424434 :param dict kwargs: Each of the named arguments will be set as
425435 attributes on the resulting Resource object.
426436 """
427- return cls (synchronized = False , ** kwargs )
437+ return cls (_synchronized = False , ** kwargs )
428438
429439 @classmethod
430440 def existing (cls , ** kwargs ):
431441 """Create an instance of an existing remote resource.
432442
433- It is marked as an exact replication of a resource present on a server.
443+ When creating the instance set the ``_synchronized`` parameter
444+ of :class:`Resource` to ``True`` to indicate that it represents the
445+ state of an existing server-side resource. As such, all attributes
446+ passed in ``**kwargs`` are considered "clean", such that an immediate
447+ :meth:`update` call would not generate a body of attributes to be
448+ modified on the server.
434449
435450 :param dict kwargs: Each of the named arguments will be set as
436451 attributes on the resulting Resource object.
437452 """
438- return cls (synchronized = True , ** kwargs )
453+ return cls (_synchronized = True , ** kwargs )
439454
440455 def to_dict (self , body = True , headers = True , ignore_none = False ):
441456 """Return a dictionary of this resource's contents
0 commit comments