mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Create a class Permissions
This commit is contained in:
@@ -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" },
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" ]
|
||||
@@ -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" ]
|
||||
|
||||
+3
-1
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user