(self, api, name, def_dict, parent=None)
Creates a Resource.

    Args:
      api: (Api) The Api which owns this Resource.
      name: (string) The discovery name of the Resource.
      def_dict: (dict) The discovery dictionary for this Resource.
      parent: (CodeObject) The resource containing this method, if any. Top
         level resources have the API as a parent.
Creates a Resource.
Creates a Resource .
def __init__(self, api, name, def_dict, parent=None):
    """Creates a Resource.

    Args:
      api: (Api) The Api which owns this Resource.
      name: (string) The discovery name of the Resource.
      def_dict: (dict) The discovery dictionary for this Resource.
      parent: (CodeObject) The resource containing this method, if any. Top
         level resources have the API as a parent.
    """
    super(Resource, self).__init__(def_dict, api, parent=parent, wire_name=name)
    self.ValidateName(name)
    class_name = api.ToClassName(name, self, element_type='resource')
    self.SetTemplateValue('className', class_name)
    # Replace methods dict with Methods
    self._methods = []
    method_dict = self.values.get('methods') or {}
    for name in sorted(method_dict):
      method = Method(api, name, method_dict[name], parent=self)
      if not self.reparent(method):
        self._methods.append(method)
    self.SetTemplateValue('methods', self._methods)
    # Get sub resources
    self._resources = []
    r_def_dict = self.values.get('resources') or {}
    for name in sorted(r_def_dict):
      resource = Resource(api, name, r_def_dict[name], parent=self)
      if not (api.get('reparentMethodsUsingId') and resource.is_skippable):
        self._resources.append(resource)
    self.SetTemplateValue('resources', self._resources)
def __init__ ( self , api , name , def_dict , parent = None ) : super ( Resource , self ) . __init__ ( def_dict , api , parent = parent , wire_name = name ) self . ValidateName ( name ) class_name = api . ToClassName ( name , self , element_type = 'resource' ) self . SetTemplateValue ( 'className' , class_name ) # Replace methods dict with Methods self . _methods = [ ] method_dict = self . values . get ( 'methods' ) or { } for name in sorted ( method_dict ) : method = Method ( api , name , method_dict [ name ] , parent = self ) if not self . reparent ( method ) : self . _methods . append ( method ) self . SetTemplateValue ( 'methods' , self . _methods ) # Get sub resources self . _resources = [ ] r_def_dict = self . values . get ( 'resources' ) or { } for name in sorted ( r_def_dict ) : resource = Resource ( api , name , r_def_dict [ name ] , parent = self ) if not ( api . get ( 'reparentMethodsUsingId' ) and resource . is_skippable ) : self . _resources . append ( resource ) self . SetTemplateValue ( 'resources' , self . _resources )