diff --git a/codegen/JsonDescriptionOfGithubApiV3/description.000.human_readable.json b/codegen/JsonDescriptionOfGithubApiV3/description.000.human_readable.json index 03adb042..6f256a60 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/description.000.human_readable.json +++ b/codegen/JsonDescriptionOfGithubApiV3/description.000.human_readable.json @@ -1210,6 +1210,16 @@ "collections": [ ] }, + { + "name": "Permissions", + "attributes": [ + { "name": "admin", "type": "bool" }, + { "name": "pull", "type": "bool" }, + { "name": "push", "type": "bool" } + ], + "collections": [ + ] + }, { "name": "Repository", "identity": [ @@ -1251,7 +1261,7 @@ { "name": "organization", "type": "Organization" }, { "name": "owner", "type": "NamedUser" }, { "name": "parent", "type": "Repository" }, - { "name": "permissions", "type": "@todo" }, + { "name": "permissions", "type": "Permissions" }, { "name": "private", "type": "bool" }, { "name": "pushed_at", "type": "string" }, { "name": "size", "type": "integer" }, diff --git a/codegen/JsonDescriptionOfGithubApiV3/description.001.normalized.json b/codegen/JsonDescriptionOfGithubApiV3/description.001.normalized.json index 2d142ef6..c58d8c5c 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/description.001.normalized.json +++ b/codegen/JsonDescriptionOfGithubApiV3/description.001.normalized.json @@ -6186,6 +6186,36 @@ } ] }, + { + "attributes": [ + { + "type": { + "simple": true, + "cardinality": "scalar", + "name": "bool" + }, + "name": "admin" + }, + { + "type": { + "simple": true, + "cardinality": "scalar", + "name": "bool" + }, + "name": "pull" + }, + { + "type": { + "simple": true, + "cardinality": "scalar", + "name": "bool" + }, + "name": "push" + } + ], + "name": "Permissions", + "methods": [] + }, { "attributes": [ { @@ -7103,9 +7133,9 @@ }, { "type": { - "simple": true, + "simple": false, "cardinality": "scalar", - "name": "@todo" + "name": "Permissions" }, "name": "permissions" }, diff --git a/doc/ReferenceOfClasses.md b/doc/ReferenceOfClasses.md index 5819685f..6a1ce996 100644 --- a/doc/ReferenceOfClasses.md +++ b/doc/ReferenceOfClasses.md @@ -790,6 +790,15 @@ Teams * `permission` * `get_teams()`: list of `Team` +Class `Permissions` +=================== + +Attributes +---------- +* `admin`: bool +* `pull`: bool +* `push`: bool + Class `Plan` ============ @@ -926,7 +935,7 @@ Attributes * `organization`: `Organization` * `owner`: `NamedUser` * `parent`: `Repository` -* `permissions` +* `permissions`: `Permissions` * `private`: bool * `pushed_at`: string * `size`: integer diff --git a/src/github/Permissions.py b/src/github/Permissions.py new file mode 100644 index 00000000..24d100db --- /dev/null +++ b/src/github/Permissions.py @@ -0,0 +1,45 @@ +# WARNING: this file is generated automaticaly. +# Do not modify it manually, your work would be lost. + +import PaginatedList +# This allows None as a valid value for an optional parameter + +class DefaultValueForOptionalParametersType: + pass +DefaultValueForOptionalParameters = DefaultValueForOptionalParametersType() + +class Permissions( object ): + def __init__( self, requester, attributes, lazy ): + self.__requester = requester + self.__completed = False + self.__initAttributes() + self.__useAttributes( attributes ) + + @property + def admin( self ): + return self.__admin + + @property + def pull( self ): + return self.__pull + + @property + def push( self ): + return self.__push + + def __initAttributes( self ): + self.__admin = None + self.__pull = None + self.__push = None + + def __useAttributes( self, attributes ): + #@todo No need to check if attribute is in attributes when attribute is mandatory + if "admin" in attributes and attributes[ "admin" ] is not None: + assert isinstance( attributes[ "admin" ], bool ) + self.__admin = attributes[ "admin" ] + if "pull" in attributes and attributes[ "pull" ] is not None: + assert isinstance( attributes[ "pull" ], bool ) + self.__pull = attributes[ "pull" ] + if "push" in attributes and attributes[ "push" ] is not None: + assert isinstance( attributes[ "push" ], bool ) + self.__push = attributes[ "push" ] diff --git a/src/github/Repository.py b/src/github/Repository.py index 6d6440e7..eff3edf8 100644 --- a/src/github/Repository.py +++ b/src/github/Repository.py @@ -14,6 +14,7 @@ import PullRequest import RepositoryKey import NamedUser import Milestone +import Permissions import CommitComment import GitCommit import Team @@ -958,7 +959,8 @@ class Repository( object ): assert isinstance( attributes[ "parent" ], dict ) self.__parent = Repository( self.__requester, attributes[ "parent" ], lazy = True ) if "permissions" in attributes and attributes[ "permissions" ] is not None: - self.__permissions = attributes[ "permissions" ] + assert isinstance( attributes[ "permissions" ], dict ) + self.__permissions = Permissions.Permissions( self.__requester, attributes[ "permissions" ], lazy = True ) if "private" in attributes and attributes[ "private" ] is not None: assert isinstance( attributes[ "private" ], bool ) self.__private = attributes[ "private" ] diff --git a/test/Repository.py b/test/Repository.py index f16db443..f8e3120a 100644 --- a/test/Repository.py +++ b/test/Repository.py @@ -28,7 +28,9 @@ class Repository( Framework.TestCase ): self.assertEqual( repo.organization, None ) self.assertEqual( repo.owner.login, "jacquev6" ) self.assertEqual( repo.parent, None ) - self.assertEqual( repo.permissions, { "admin": True, "pull": True, "push": True } ) ### @todo Create a Permission class + self.assertEqual( repo.permissions.admin, True ) + self.assertEqual( repo.permissions.pull, True ) + self.assertEqual( repo.permissions.push, True ) self.assertEqual( repo.private, False ) self.assertEqual( repo.pushed_at, "2012-05-08T19:27:43Z" ) self.assertEqual( repo.size, 212 )