Exemplo n.º 1
0
    def authorizePermission(self, token, id, client_id, *permission_id):
        """
            Args:\n
            token:str -> You must have the access token.\n
            id -> API id
            client_ids -> Client ID
            permission_id -> Permission Id's

            Returns: Authorize permissions for the client

            Documentation: https://docs.plusauth.com/api/core/apis/authorizePermissionForClient?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        self.client_id = client_id
        permission_id_array = list(permission_id)
        data = {'permission_id_array': permission_id_array}
        res = requests.post(base_url +
                            "apis/{}/authorized_clients/{}/permissions".format(
                                self.id, self.client_id),
                            data=data,
                            headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 2
0
    def update(self, token, id, name, description='', assignOnSignup=True):
        """
            Args: \n
            token:str -> You must have the access token.\n
            name -> str \n
            description -> Description \n
            assignOnSignup -> Boolean \n

            Returns: Update Role

            Documentation: https://docs.plusauth.com/api/core/roles/updateRole?lang=shell

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload = {
            'name': name,
            'description': description,
            'assignOnSignup': assignOnSignup
        }
        res = requests.patch(base_url + "roles/{}".format(self.id),
                             data=payload,
                             headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 3
0
    def delete(self , token , id ):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> Role Group id

            Returns: Delete Role Group

            Documentation: https://docs.plusauth.com/api/core/roleGroups/deleteRoleGroup?lang=python

        """
        headers = Base().headers_no_type(token)
        self.id = id
        res = requests.delete(base_url + "roleGroups/{}".format(self.id), headers=headers)
        return res
Exemplo n.º 4
0
    def create(self , token , username =''  , password = '' , blocked ='' , user_details ='' ):
        """
            Args:\n
            token:str -> You must have the access token.\n

            Returns: Create new User

            Documentation: https://docs.plusauth.com/api/core/users/createUser

        """
        headers = Base().headers_content_tpye_json(token)
        payload = {'username': username, 'password': password, 'blocked': blocked , 'user_details': user_details}
        res = requests.post(base_url + "users", data=payload, headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 5
0
    def delete(self , token , id ):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> Tenant id

            Returns: Delete Tenant

            Documentation: https://docs.plusauth.com/api/core/tenants/deleteTenant

        """
        headers = Base().headers_no_type(token)
        self.id = id
        res = requests.delete(base_url + "tenants/{}".format(self.id), headers=headers)
        return res
Exemplo n.º 6
0
    def delete(self, token, id):
        """
            Args: \n
            id:str -> API id \n

            Returns: Delete an existing API.

            Documentation : https://docs.plusauth.com/api/core/apis/deleteApi?lang=python

        """
        headers = Base().headers_no_type(token)
        self.id = id
        res = requests.delete(base_url + "apis/{}".format(self.id),
                              headers=headers)
        return res
Exemplo n.º 7
0
    def get(self , token , id ):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> User id

            Returns: Retrieve User

            Documentation: https://docs.plusauth.com/api/core/users/getUser

        """
        headers = Base().headers_no_type(token)
        self.id = id
        res = requests.get(base_url + "users/{}".format(self.id), headers=headers)
        res_j=res.json()
        return res_j
Exemplo n.º 8
0
    def getSettings(self , token , id ):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> Tenant id

            Returns: Get Tenant settings

            Documentation: https://docs.plusauth.com/api/core/tenants/getTenantSettings

        """
        headers = Base().headers_no_type(token)
        self.id = id
        res = requests.get(base_url + "tenants/{}/settings".format(self.id), headers=headers)
        res_j=res.json()
        return res_j
Exemplo n.º 9
0
    def unassignRoles(self , token , id , role_id = ''):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> User id
            role_group_id -> Role  Ids

            Returns: Unassign directly assigned Roles from user

            Documentation: https://docs.plusauth.com/api/core/users/unassignDirectlyAssignedRolesFromUser

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload ={'role_id': role_id }
        res = requests.delete(base_url + "users/{}/roles".format(self, id), data=payload, headers=headers)
        return res.text
Exemplo n.º 10
0
    def get(self, token, type):
        """
            Args: \n
            token:str -> You must have the access token.\n
            type:str -> View type

            Returns: Get View

            Documentation: https://docs.plusauth.com/api/core/views/getView
            
        """
        headers = Base().headers_no_type(token)
        self.type = type
        res = requests.get(base_url + "views/{}".format(self.type),
                           headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 11
0
    def create(self , token , tenant_id , region ,settings = ''):
        """
            Args: \n
            token:str -> You must have the access token.\n
            tenant_id:str -> Tenant id \n
            region -> str \n
            settings -> Detailed information in documentation .

            Returns: Create Tenant

            Documentation: https://docs.plusauth.com/api/core/tenants/createTenant
        """
        headers = Base().headers_content_tpye_json(token)
        payload = { 'tenant_id' :tenant_id , 'region' : region , 'settings' : settings }
        res =requests.post(base_url+"tenants" , data = payload , headers =headers )
        res_j =res.json()
        return  res_j
Exemplo n.º 12
0
    def update(self , token , id , username =''  , password = '' , blocked ='' , user_details ='' ):
        """
            Args:\n
            token:str -> You must have the access token.\n
            id:str -> User id

            Returns: Update User

            Documentation: https://docs.plusauth.com/api/core/users/updateUser

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload = {'username': username, 'password': password, 'blocked': blocked , 'user_details': user_details}
        res = requests.patch(base_url + "users/{}".format(self,id), data=payload, headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 13
0
    def get(self, token, id):
        """
            Args:\n
            token:str -> You must have the access token.\n
            id:str ->API id

            Returns: Get the permissions that this API uses

            Documentation: https://docs.plusauth.com/api/core/permissions/getApiPermissions?lang=python

        """
        headers = Base().headers_no_type(token)
        self.id = id
        res = requests.get(base_url + "apis/{}permissions".format(self.id),
                           headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 14
0
    def getPermissions(self, token, id):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> Role id

            Returns: Retrieve Permissions assigned to Role

            Documentation: https://docs.plusauth.com/api/core/roles/getRolePermissions?lang=python

        """
        headers = Base().headers_no_type(token)
        self.id = id
        res = requests.get(base_url + "roles/{}/permissions".format(self.id),
                           headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 15
0
    def unassignPermission(self , token , id , permissions_id = ''):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> User id
            permissions_id -> Permission Ids


            Returns: Unassign directly assigned permission from User

            Documentation: https://docs.plusauth.com/api/core/users/unassignDirectlyAssignedPermission

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload ={'permissions_id': permissions_id }
        res = requests.delete(base_url + "users/{}/permissions".format(self, id), data=payload, headers=headers)
        return res.text
Exemplo n.º 16
0
    def getAuthorizedClients(self, token, id):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> API id

            Returns: Get clients authorized for the api.

            Documentation : https://docs.plusauth.com/api/core/apis/getApiAuthorizedClients?lang=python

        """
        headers = Base().headers_no_type(token)
        self.id = id
        res = requests.get(base_url +
                           "apis/{}/authorized_clients".format(self.id),
                           headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 17
0
    def getAll(self , token , page = '' , itemsPerPage = '' , sortBy = '' , sortDesc = '' ):
        """
            Args: \n
            token:str -> You must have the access token.\n
            page -> The number of records you wish to skip before selecting records \n
            itemsPerPage -> Limit the number of results returned \n
            sortBy -> Properties that should be ordered by \n
            sortDesc -> Descending or ascending or nothing \n

            Returns: List all Tenants

            Documentation: https://docs.plusauth.com/api/core/tenants/listTenants
        """
        headers = Base().headers_no_type(token)
        payload = {'page': page, 'itemsPerPage': itemsPerPage, 'sortBy': sortBy, 'sortDesc': sortDesc}
        res = requests.get(base_url + "tenants", params=payload, headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 18
0
    def assignRoleGroups(self , token , id , role_group_id = ''):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> User id
            role_group_id -> Role Group Ids

            Returns: Assign Role group to User

            Documentation: https://docs.plusauth.com/api/core/users/assignRoleGroupToUser

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload ={'role_group_id': role_group_id }
        res = requests.post(base_url + "users/{}/roles".format(self, id), data=payload, headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 19
0
    def create(self , token , name , description = '' , assignOnSignup = True ):
        """
            Args: \n
            token:str -> You must have the access token.\n
            name -> str \n
            description -> Description \n
            assignOnSignup -> Boolean \n

            Returns: Create new Role Group

            Documentation: https://docs.plusauth.com/api/core/roleGroups/createRoleGroup?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        payload = {'name': name , 'description' : description , 'assignOnSignup' : assignOnSignup }
        res =requests.post(base_url+"roleGroups" , data= payload , headers = headers)
        res_j =res.json()
        return res_j
Exemplo n.º 20
0
    def removeRole(self , token , id , role_id = '' ):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> Role Group id \n
            role_id -> Role Id's \n

            Returns: Unassign Roles from Role Group

            Documentation: https://docs.plusauth.com/api/core/roleGroups/removeRolesFromRoleGroup?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload = {'role_id' :role_id }
        res = requests.delete(base_url + "roleGroups/{}/roles".format(self.id), params=payload, headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 21
0
    def update(self, token, type, html_content=''):
        """
            Args: Args: \n
            token:str -> You must have the access token.\n
            type:str -> View type\n
            html_content -> View html content

            Returns: Update View

            Documentation: https://docs.plusauth.com/api/core/views/updateView

        """
        headers = Base().headers_content_type_text(token)
        self.type = type
        payload = {'html_content': html_content}
        res = requests.patch(base_url + "views/{}".format(self.type),
                             data=payload,
                             headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 22
0
    def delete(self, token, id, permission_id):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> API id \n
            permission_id:str -> Permission id \n

            Returns: Delete permission

            Documentation: https://docs.plusauth.com/api/core/permissions/deletePermission?lang=python

        """
        headers = Base().headers_no_type(token)
        self.id = id
        self.permission_id = permission_id
        res = requests.delete(
            base_url +
            "apis/{}/permissions/{}".format(self.id, self.permission_id),
            headers=headers)
        return res
Exemplo n.º 23
0
    def create(self, token, id, name, description=''):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> API id \n
            name ->Name

            Returns: Add a new permission to this API.

            Documentation: https://docs.plusauth.com/api/core/permissions/createPermission?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload = {'name': name, 'description': description}
        res = requests.post(base_url + "apis/{}/permissions".format(self.id),
                            data=payload,
                            headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 24
0
    def removePermissions(self, token, id, permissions_id=''):
        """
            Args:  \n
            token:str -> You must have the access token.\n
            id:str -> Role id \n
            permissions_id -> Permission Ids \n

            Returns:Unassign Permissions from Role

            Documentation: https://docs.plusauth.com/api/core/roles/removePermissionsFromRole?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload = {'permissions_id': permissions_id}
        res = requests.delete(base_url +
                              "roles/{}/permissions".format(self.id),
                              data=payload,
                              headers=headers)
        return res
Exemplo n.º 25
0
    def update(self, token, id, name='', description=''):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> API id \n
            name -> Updated name of Api \n
            description -> Updated description of Api \n

            Returns: Update an existing API.

            Documentation : https://docs.plusauth.com/api/core/apis/updateApi?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        data = {'name': name, 'description': description}
        res = requests.patch(base_url + "apis/{}".format(self.id),
                             data=data,
                             headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 26
0
    def authorizeClients(self, token, id, client_ids=''):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id -> API id
            client_ids -> Client ID's

            Returns: Authorize Clients to Api .

            Documentation : https://docs.plusauth.com/api/core/apis/authorizeClientsToApi?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        data = {'client_ids': client_ids}
        res = requests.post(base_url +
                            "apis/{}/authorized_clients".format(self.id),
                            data=data,
                            headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 27
0
    def getRoles(self , token , id , page = '' , itemsPerPage = '' , sortBy = '' , sortDesc = '' ):
        """
            Args: \n
            token:str -> You must have the access token.\n
            id:str -> Role Group id \n
            page -> The number of records you wish to skip before selecting records \n
            itemsPerPage -> Limit the number of results returned \n
            sortBy -> Properties that should be ordered by \n
            sortDesc -> Descending or ascending or nothing \n

            Returns:Retrieve Roles assigned to Role Group

            Documentation: https://docs.plusauth.com/api/core/roleGroups/getRoleGroupRoles?lang=python

        """
        headers = Base().headers_no_type(token)
        self.id = id
        payload = {'page': page, 'itemsPerPage': itemsPerPage, 'sortBy': sortBy, 'sortDesc': sortDesc}
        res = requests.get(base_url + "roleGroups/{}/roles".format(self.id), params=payload, headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 28
0
    def unauthorizeClients(self, token, id, client_id=''):
        """
            Args:\n
            token:str -> You must have the access token.\n
            id -> API id
            client_ids -> Client ID's

            Returns: Unauthorize client/s for the api.

            Documentation : https://docs.plusauth.com/api/core/apis/unauthorizeClientsForApi?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload = {'client_id': client_id}
        res = requests.delete(base_url +
                              "apis/{}/authorized_clients".format(self.id),
                              data=payload,
                              headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 29
0
    def addPermission(self, token, id, permissions_id=''):
        """
            Args:  \n
            token:str -> You must have the access token.\n
            id:str -> Role id
            permissions_id -> Permission Ids


            Returns: Assign Permission to a Role

            Documentation: https://docs.plusauth.com/api/core/roles/addPermissionToRole?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        self.id = id
        payload = {'permissions_id': permissions_id}
        res = requests.post(base_url + "roles/{}/permissions".format(self.id),
                            data=payload,
                            headers=headers)
        res_j = res.json()
        return res_j
Exemplo n.º 30
0
    def create(self, token, name, audience, description=''):
        """
            Args: \n
            token:str -> You must have the access token.\n
            name -> Name for Api\n
            audience -> Identifier for the Api. It cannot be changed after created. Received tokens will contain this field as aud parameter. \n
            description -> Additional information about Api \n

            Returns: Create new APIs

            Documentation : https://docs.plusauth.com/api/core/apis/createApi?lang=python

        """
        headers = Base().headers_content_tpye_json(token)
        payload = {
            'name': name,
            'audience': audience,
            'description': description
        }
        res = requests.post(base_url + "apis", data=payload, headers=headers)
        res_j = res.json()
        return res_j