Open kevinhillinger opened 1 year ago
class Offer(Model):
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'alias': {'key': 'alias', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'}
}
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.id = kwargs.get('id', None)
self.alias = kwargs.get('alias', None)
self.type = kwargs.get('type', None)
self._resource = kwargs.get('resource', None)
Usage: offer_resource_id = offer.resource.durable_id
But, then we should consider if the field should be adjusted the same way in 'Plan' and 'PlanListing'.
class Offer(Model):
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'alias': {'key': 'alias', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'}
}
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.id = kwargs.get('id', None)
self.alias = kwargs.get('alias', None)
self.type = kwargs.get('type', None)
self._resource = kwargs.get('resource', None)
def durable_id(self):
return self._resource.durable_id
Usage: offer_resource_id = offer.durable_id
This PR in my fork demos what this change would look like - https://github.com/dciborow/partnercenter-cli-extension/pull/15/files
(this is more pythonic then making a function def resource(self): return self._resource
)
@dciborow submitted PR for azure/partnercenter-cli-extension#186 noting the issue with the syntax and that it violated linting rules.
Link to comment thread
We need to continue to support out of the box behavior that the CLI gives us inheriting from
msrest.serialization.Model
while having a pythonic and clean way for it to ignore the field when serializing out from the CLI.