How to use the pyral.entity.DomainObject function in pyral

To help you get started, we’ve selected a few pyral examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RallyTools / RallyRestToolkitForPython / pyral / restapi.py View on Github external
collection_attributes = [attr_name for attr_name in list(item_data.keys())
                                            if attr_name.lower == 'children'
                                            or attr_name[-1] == 's'
                                ]
        if not collection_attributes:
            return item_data
        for attr_name in collection_attributes:
            if type(item_data[attr_name]) != list:
                continue
            obj_list = []
            for value in item_data[attr_name]:
                # is value like "someentityname/34223214" ?
                if (type(value) == str or type(value) == bytes) and '/' in value \
                and re.match(r'^\d+$', value.split('/')[-1]):
                    obj_list.append({"_ref" : value})  # transform to a dict instance
                elif issubclass(value.__class__, DomainObject):
                    obj_list.append({"_ref" : value.ref})  # put the ref in a dict instance
                else:
                    obj_list.append(value)   # value is untouched
            item_data[attr_name] = obj_list
        return item_data
github RallyTools / RallyRestToolkitForPython / pyral / entity.py View on Github external
continue
            if 'pyral.entity.' not in str(type(value)):
                anv = '    %-24s  : %s' % (attribute_name, value)
            else:
                mo = re.search(r' \'pyral.entity.(\w+)\'>', str(type(value)))
                if mo:
                    cln = mo.group(1)
                    anv = "    %-24s  : %-14.14s   (OID  %s  Name: %s)" % \
                          (attribute_name, cln + '.ref', value.oid, value.Name)
                else:
                    anv = "    %-24s  : %s" % value
            tank.append(anv)
            
        return "\n".join(tank)

class Workspace       (DomainObject): pass
class Blocker         (DomainObject): pass
class UserPermission  (DomainObject): pass
class WorkspacePermission   (UserPermission): pass
class ProjectPermission     (UserPermission): pass

class WorkspaceDomainObject(DomainObject):
    """ 
        This is an Abstract Base class, with a convenience method (details) that  
        formats the attrbutes and corresponding values into an easily viewable
        mulitiline string representation.
    """
    COMMON_ATTRIBUTES = ['_type', 
                         'oid', 'ref', 'ObjectID', 'ObjectUUID', '_ref', 
                         '_CreatedAt', '_hydrated', 
                         'Name', 'Subscription', 'Workspace', 
                         'FormattedID'
github RallyTools / RallyRestToolkitForPython / pyral / entity.py View on Github external
if 'pyral.entity.' not in str(type(value)):
                anv = '    %-24s  : %s' % (attribute_name, value)
            else:
                mo = re.search(r' \'pyral.entity.(\w+)\'>', str(type(value)))
                if mo:
                    cln = mo.group(1)
                    anv = "    %-24s  : %-14.14s   (OID  %s  Name: %s)" % \
                          (attribute_name, cln + '.ref', value.oid, value.Name)
                else:
                    anv = "    %-24s  : %s" % value
            tank.append(anv)
            
        return "\n".join(tank)

class Workspace       (DomainObject): pass
class Blocker         (DomainObject): pass
class UserPermission  (DomainObject): pass
class WorkspacePermission   (UserPermission): pass
class ProjectPermission     (UserPermission): pass

class WorkspaceDomainObject(DomainObject):
    """ 
        This is an Abstract Base class, with a convenience method (details) that  
        formats the attrbutes and corresponding values into an easily viewable
        mulitiline string representation.
    """
    COMMON_ATTRIBUTES = ['_type', 
                         'oid', 'ref', 'ObjectID', 'ObjectUUID', '_ref', 
                         '_CreatedAt', '_hydrated', 
                         'Name', 'Subscription', 'Workspace', 
                         'FormattedID'
                        ]
github RallyTools / RallyRestToolkitForPython / pyral / entity.py View on Github external
if item == 'MatchingText':
            # scrub out the alm specific html tags 
            scrubbed = re.sub(self.tagged_field_name_pattern, so_element_text, value)
            scrubbed = re.sub(self.bolding_pattern, so_bolded_text, scrubbed)
            self.__dict__[item] = scrubbed
        return self.__dict__[item]

#################################################################################################

# ultimately, the classFor dict is what is intended to be exposed as a means to limit
# instantiation to concrete classes, although because of dyna-types that is no longer
# very strictly enforced
# 

classFor = { 'Persistable'             : Persistable,
             'DomainObject'            : DomainObject,
             'WorkspaceDomainObject'   : WorkspaceDomainObject,
             'Subscription'            : Subscription,
             'User'                    : User,
             'UserProfile'             : UserProfile,
             'UserPermission'          : UserPermission,
             'Workspace'               : Workspace,
             'WorkspaceConfiguration'  : WorkspaceConfiguration,
             'WorkspacePermission'     : WorkspacePermission,
             'Type'                    : Type,
             'TypeDefinition'          : TypeDefinition,
             'AttributeDefinition'     : AttributeDefinition,
             'Program'                 : Program,
             'Project'                 : Project,
             'ProjectPermission'       : ProjectPermission,
             'Artifact'                : Artifact,
             'ArtifactNotification'    : ArtifactNotification,
github RallyTools / RallyRestToolkitForPython / pyral / entity.py View on Github external
anv = '    %-24s  : %s' % (attribute_name, value)
            else:
                mo = re.search(r' \'pyral.entity.(\w+)\'>', str(type(value)))
                if mo:
                    cln = mo.group(1)
                    anv = "    %-24s  : %-14.14s   (OID  %s  Name: %s)" % \
                          (attribute_name, cln + '.ref', value.oid, value.Name)
                else:
                    anv = "    %-24s  : %s" % value
            tank.append(anv)
            
        return "\n".join(tank)

class Workspace       (DomainObject): pass
class Blocker         (DomainObject): pass
class UserPermission  (DomainObject): pass
class WorkspacePermission   (UserPermission): pass
class ProjectPermission     (UserPermission): pass

class WorkspaceDomainObject(DomainObject):
    """ 
        This is an Abstract Base class, with a convenience method (details) that  
        formats the attrbutes and corresponding values into an easily viewable
        mulitiline string representation.
    """
    COMMON_ATTRIBUTES = ['_type', 
                         'oid', 'ref', 'ObjectID', 'ObjectUUID', '_ref', 
                         '_CreatedAt', '_hydrated', 
                         'Name', 'Subscription', 'Workspace', 
                         'FormattedID'
                        ]
github RallyTools / RallyRestToolkitForPython / pyral / entity.py View on Github external
if value is None:
                continue
            if 'pyral.entity.' not in str(type(value)):
                anv = '    %-20s  : %s' % (attribute_name, value)
            else:
                mo = re.search(r' \'pyral.entity.(\w+)\'>', str(type(value)))
                if mo:
                    cln = mo.group(1)  # cln -- class name
                    anv = "    %-20s  : %-20.20s   (OID  %s  Name: %s)" % \
                          (attribute_name, cln + '.ref', value.oid, value.Name)
                else:
                    anv = "    %-20s  : %s" % value
            tank.append(anv)
        return "\n".join(tank)

class UserProfile     (DomainObject):
    USER_PROFILE_ATTRIBUTES = ['oid', 'ref', 'ObjectID', 'ObjectUUID', '_ref',
                               '_CreatedAt', '_hydrated', 
                               'DefaultWorkspace', 'DefaultProject',
                               'TimeZone',
                               'DateFormat', 'DateTimeFormat',
                               'SessionTimeoutSeconds', 'SessionTimeoutWarning',
                               'EmailNotificationEnabled', 
                               'WelcomePageHidden'
                              ]
    def details(self):
        """
            Assemble a list of USER_PROFILE_ATTRIBUTES and values 
            and join it into a single string with newline "delimiters".
            Return this string so that the caller can simply print it and have
            a nicely formatted block of information about the specific User.
        """
github RallyTools / RallyRestToolkitForPython / pyral / entity.py View on Github external
cln = mo.group(1)
                    anv = "    %-24s  : %-14.14s   (OID  %s  Name: %s)" % \
                          (attribute_name, cln + '.ref', value.oid, value.Name)
                else:
                    anv = "    %-24s  : %s" % value
            tank.append(anv)
            
        return "\n".join(tank)

class Workspace       (DomainObject): pass
class Blocker         (DomainObject): pass
class UserPermission  (DomainObject): pass
class WorkspacePermission   (UserPermission): pass
class ProjectPermission     (UserPermission): pass

class WorkspaceDomainObject(DomainObject):
    """ 
        This is an Abstract Base class, with a convenience method (details) that  
        formats the attrbutes and corresponding values into an easily viewable
        mulitiline string representation.
    """
    COMMON_ATTRIBUTES = ['_type', 
                         'oid', 'ref', 'ObjectID', 'ObjectUUID', '_ref', 
                         '_CreatedAt', '_hydrated', 
                         'Name', 'Subscription', 'Workspace', 
                         'FormattedID'
                        ]

    def details(self):
        """
            order we want to have the attributes appear in...
github RallyTools / RallyRestToolkitForPython / pyral / entity.py View on Github external
##################################################################################################
#
# subclasses (both abstract and concrete) that descend from Persistable
#

class Subscription(Persistable):  pass

class AllowedAttributeValue(Persistable):  pass  # only used in an AttributeDefinition
class AllowedQueryOperator (Persistable):  pass  # only used in an AttributeDefinition 
                                                 #  (for AllowedQueryOperators)

class DomainObject(Persistable):
    """ This is an Abstract Base class """
    pass

class User (DomainObject): 
    USER_ATTRIBUTES = ['oid', 'ref', 'ObjectID', 'ObjectUUID', '_ref', 
                       '_CreatedAt', '_hydrated', 
                       'UserName', 'DisplayName', 'EmailAddress', 
                       'FirstName', 'MiddleName', 'LastName', 
                       'ShortDisplayName', 
                       'SubscriptionAdmin',
                       'Role',
                       'UserPermissions',
                       #'TeamMemberships',
                       #'UserProfile'
                      ]
    def details(self):
        """
            Assemble a list of USER_ATTRIBUTES and values 
            and join it into a single string with newline "delimiters".
            Return this string so that the caller can simply print it and have