mirror of
https://github.com/thousandeyes/thousandeyes-sdk-python.git
synced 2025-12-06 06:26:51 +00:00
421 lines
17 KiB
Python
421 lines
17 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Administrative API
|
|
|
|
Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management).
|
|
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
|
|
import json
|
|
import unittest
|
|
import thousandeyes_sdk.administrative.models
|
|
|
|
from .test_utils import assert_constructed_model_matches_example_json
|
|
from thousandeyes_sdk.administrative.api.users_api import UsersApi
|
|
|
|
|
|
class TestUsersApi(unittest.TestCase):
|
|
"""UsersApi unit test stubs"""
|
|
|
|
def setUp(self) -> None:
|
|
self.api = UsersApi()
|
|
|
|
def tearDown(self) -> None:
|
|
pass
|
|
|
|
def test_create_user_models_validation(self) -> None:
|
|
"""Test case for create_user request and response models"""
|
|
request_body_json = """
|
|
{
|
|
"loginAccountGroupId" : "691",
|
|
"accountGroupRoles" : [ {
|
|
"roleIds" : [ "57", "1140" ],
|
|
"accountGroupId" : "315"
|
|
}, {
|
|
"roleIds" : [ "57", "1140" ],
|
|
"accountGroupId" : "315"
|
|
} ],
|
|
"name" : "User X",
|
|
"allAccountGroupRoleIds" : [ "57", "1140" ],
|
|
"email" : "userx@thousandeyes.com"
|
|
}"""
|
|
|
|
request_loaded_json = json.loads(request_body_json)
|
|
request_from_json = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json)
|
|
assert_constructed_model_matches_example_json(request_from_json, request_loaded_json)
|
|
|
|
response_body_json = """
|
|
{
|
|
"loginAccountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
},
|
|
"uid" : "245",
|
|
"allAccountGroupRoles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"accountGroupRoles" : [ {
|
|
"roles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"accountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
}
|
|
}, {
|
|
"roles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"accountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
}
|
|
} ],
|
|
"name" : "User X",
|
|
"email" : "userx@thousandeyes.com",
|
|
"dateRegistered" : "2020-07-17T22:00:54Z"
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_json = thousandeyes_sdk.administrative.models.CreatedUser.from_json(response_body_json)
|
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
|
|
|
def test_delete_user_models_validation(self) -> None:
|
|
"""Test case for delete_user request and response models"""
|
|
|
|
|
|
def test_get_current_user_models_validation(self) -> None:
|
|
"""Test case for get_current_user request and response models"""
|
|
|
|
response_body_json = """
|
|
{
|
|
"loginAccountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
},
|
|
"uid" : "245",
|
|
"lastLogin" : "2022-07-17T22:00:54Z",
|
|
"allAccountGroupRoles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"accountGroupRoles" : [ {
|
|
"roles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"accountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
}
|
|
}, {
|
|
"roles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"accountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
}
|
|
} ],
|
|
"name" : "User X",
|
|
"email" : "userx@thousandeyes.com",
|
|
"dateRegistered" : "2020-07-17T22:00:54Z"
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_json = thousandeyes_sdk.administrative.models.UserDetail.from_json(response_body_json)
|
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
|
|
|
def test_get_user_models_validation(self) -> None:
|
|
"""Test case for get_user request and response models"""
|
|
|
|
response_body_json = """
|
|
{
|
|
"loginAccountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
},
|
|
"uid" : "245",
|
|
"lastLogin" : "2022-07-17T22:00:54Z",
|
|
"allAccountGroupRoles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"accountGroupRoles" : [ {
|
|
"roles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"accountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
}
|
|
}, {
|
|
"roles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"accountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
}
|
|
} ],
|
|
"name" : "User X",
|
|
"email" : "userx@thousandeyes.com",
|
|
"dateRegistered" : "2020-07-17T22:00:54Z"
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_json = thousandeyes_sdk.administrative.models.UserDetail.from_json(response_body_json)
|
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
|
|
|
def test_get_users_models_validation(self) -> None:
|
|
"""Test case for get_users request and response models"""
|
|
|
|
response_body_json = """
|
|
{
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"users" : [ {
|
|
"loginAccountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
},
|
|
"uid" : "245",
|
|
"lastLogin" : "2022-07-17T22:00:54Z",
|
|
"name" : "User X",
|
|
"email" : "userx@thousandeyes.com",
|
|
"dateRegistered" : "2020-07-17T22:00:54Z"
|
|
}, {
|
|
"loginAccountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
},
|
|
"uid" : "245",
|
|
"lastLogin" : "2022-07-17T22:00:54Z",
|
|
"name" : "User X",
|
|
"email" : "userx@thousandeyes.com",
|
|
"dateRegistered" : "2020-07-17T22:00:54Z"
|
|
} ]
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_json = thousandeyes_sdk.administrative.models.Users.from_json(response_body_json)
|
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
|
|
|
def test_update_user_models_validation(self) -> None:
|
|
"""Test case for update_user request and response models"""
|
|
request_body_json = """
|
|
{
|
|
"loginAccountGroupId" : "691",
|
|
"accountGroupRoles" : [ {
|
|
"roleIds" : [ "57", "1140" ],
|
|
"accountGroupId" : "315"
|
|
}, {
|
|
"roleIds" : [ "57", "1140" ],
|
|
"accountGroupId" : "315"
|
|
} ],
|
|
"name" : "User X",
|
|
"allAccountGroupRoleIds" : [ "57", "1140" ],
|
|
"email" : "userx@thousandeyes.com"
|
|
}"""
|
|
|
|
request_loaded_json = json.loads(request_body_json)
|
|
request_from_json = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json)
|
|
assert_constructed_model_matches_example_json(request_from_json, request_loaded_json)
|
|
|
|
response_body_json = """
|
|
{
|
|
"loginAccountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
},
|
|
"uid" : "245",
|
|
"lastLogin" : "2022-07-17T22:00:54Z",
|
|
"allAccountGroupRoles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"accountGroupRoles" : [ {
|
|
"roles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"accountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
}
|
|
}, {
|
|
"roles" : [ {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
}, {
|
|
"roleId" : "35",
|
|
"name" : "Organization Admin",
|
|
"isBuiltin" : true,
|
|
"hasManagementPermissions" : true
|
|
} ],
|
|
"accountGroup" : {
|
|
"accountGroupName" : "Account A",
|
|
"aid" : "1234"
|
|
}
|
|
} ],
|
|
"name" : "User X",
|
|
"email" : "userx@thousandeyes.com",
|
|
"dateRegistered" : "2020-07-17T22:00:54Z"
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_json = thousandeyes_sdk.administrative.models.UserDetail.from_json(response_body_json)
|
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|