mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-15 21:23:17 +00:00
Add user-related GraphQL handlers
This commit is contained in:
parent
88a1393a1d
commit
33b8003f07
|
@ -4,35 +4,16 @@ fragment basicMutationReturnFields on MutationReturnInterface{
|
||||||
success
|
success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fragment userFields on User{
|
||||||
mutation CreateUser($user: UserMutationInput!) {
|
|
||||||
createUser(user: $user) {
|
|
||||||
...basicMutationReturnFields
|
|
||||||
user {
|
|
||||||
username
|
username
|
||||||
userType
|
userType
|
||||||
sshKeys
|
sshKeys
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
query AllUsers {
|
query AllUsers {
|
||||||
users {
|
users {
|
||||||
allUsers {
|
allUsers {
|
||||||
userType
|
...userFields
|
||||||
username
|
|
||||||
sshKeys
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mutation AddSshKey($sshInput: SshMutationInput!) {
|
|
||||||
addSshKey(sshInput: $sshInput) {
|
|
||||||
...basicMutationReturnFields
|
|
||||||
user {
|
|
||||||
sshKeys
|
|
||||||
userType
|
|
||||||
username
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,20 +21,16 @@ mutation AddSshKey($sshInput: SshMutationInput!) {
|
||||||
query GetUser($username: String!) {
|
query GetUser($username: String!) {
|
||||||
users {
|
users {
|
||||||
getUser(username: $username) {
|
getUser(username: $username) {
|
||||||
sshKeys
|
...userFields
|
||||||
userType
|
|
||||||
username
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutation RemoveSshKey($sshInput: SshMutationInput!) {
|
mutation CreateUser($user: UserMutationInput!) {
|
||||||
removeSshKey(sshInput: $sshInput) {
|
createUser(user: $user) {
|
||||||
...basicMutationReturnFields
|
...basicMutationReturnFields
|
||||||
user {
|
user {
|
||||||
sshKeys
|
...userFields
|
||||||
userType
|
|
||||||
username
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,9 +45,25 @@ mutation UpdateUser($user: UserMutationInput!) {
|
||||||
updateUser(user: $user) {
|
updateUser(user: $user) {
|
||||||
...basicMutationReturnFields
|
...basicMutationReturnFields
|
||||||
user {
|
user {
|
||||||
sshKeys
|
...userFields
|
||||||
userType
|
}
|
||||||
username
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mutation AddSshKey($sshInput: SshMutationInput!) {
|
||||||
|
addSshKey(sshInput: $sshInput) {
|
||||||
|
...basicMutationReturnFields
|
||||||
|
user {
|
||||||
|
...userFields
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mutation RemoveSshKey($sshInput: SshMutationInput!) {
|
||||||
|
removeSshKey(sshInput: $sshInput) {
|
||||||
|
...basicMutationReturnFields
|
||||||
|
user {
|
||||||
|
...userFields
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -24,6 +24,102 @@ Map<String, dynamic> _$Fragment$basicMutationReturnFieldsToJson(
|
||||||
'__typename': instance.$__typename,
|
'__typename': instance.$__typename,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Fragment$userFields _$Fragment$userFieldsFromJson(Map<String, dynamic> json) =>
|
||||||
|
Fragment$userFields(
|
||||||
|
username: json['username'] as String,
|
||||||
|
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'],
|
||||||
|
unknownValue: Enum$UserType.$unknown),
|
||||||
|
sshKeys:
|
||||||
|
(json['sshKeys'] as List<dynamic>).map((e) => e as String).toList(),
|
||||||
|
$__typename: json['__typename'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Fragment$userFieldsToJson(
|
||||||
|
Fragment$userFields instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'username': instance.username,
|
||||||
|
'userType': _$Enum$UserTypeEnumMap[instance.userType]!,
|
||||||
|
'sshKeys': instance.sshKeys,
|
||||||
|
'__typename': instance.$__typename,
|
||||||
|
};
|
||||||
|
|
||||||
|
const _$Enum$UserTypeEnumMap = {
|
||||||
|
Enum$UserType.NORMAL: 'NORMAL',
|
||||||
|
Enum$UserType.PRIMARY: 'PRIMARY',
|
||||||
|
Enum$UserType.ROOT: 'ROOT',
|
||||||
|
Enum$UserType.$unknown: r'$unknown',
|
||||||
|
};
|
||||||
|
|
||||||
|
Query$AllUsers _$Query$AllUsersFromJson(Map<String, dynamic> json) =>
|
||||||
|
Query$AllUsers(
|
||||||
|
users:
|
||||||
|
Query$AllUsers$users.fromJson(json['users'] as Map<String, dynamic>),
|
||||||
|
$__typename: json['__typename'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Query$AllUsersToJson(Query$AllUsers instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'users': instance.users.toJson(),
|
||||||
|
'__typename': instance.$__typename,
|
||||||
|
};
|
||||||
|
|
||||||
|
Query$AllUsers$users _$Query$AllUsers$usersFromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
Query$AllUsers$users(
|
||||||
|
allUsers: (json['allUsers'] as List<dynamic>)
|
||||||
|
.map((e) => Fragment$userFields.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList(),
|
||||||
|
$__typename: json['__typename'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Query$AllUsers$usersToJson(
|
||||||
|
Query$AllUsers$users instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'allUsers': instance.allUsers.map((e) => e.toJson()).toList(),
|
||||||
|
'__typename': instance.$__typename,
|
||||||
|
};
|
||||||
|
|
||||||
|
Variables$Query$GetUser _$Variables$Query$GetUserFromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
Variables$Query$GetUser(
|
||||||
|
username: json['username'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Variables$Query$GetUserToJson(
|
||||||
|
Variables$Query$GetUser instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'username': instance.username,
|
||||||
|
};
|
||||||
|
|
||||||
|
Query$GetUser _$Query$GetUserFromJson(Map<String, dynamic> json) =>
|
||||||
|
Query$GetUser(
|
||||||
|
users:
|
||||||
|
Query$GetUser$users.fromJson(json['users'] as Map<String, dynamic>),
|
||||||
|
$__typename: json['__typename'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Query$GetUserToJson(Query$GetUser instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'users': instance.users.toJson(),
|
||||||
|
'__typename': instance.$__typename,
|
||||||
|
};
|
||||||
|
|
||||||
|
Query$GetUser$users _$Query$GetUser$usersFromJson(Map<String, dynamic> json) =>
|
||||||
|
Query$GetUser$users(
|
||||||
|
getUser: json['getUser'] == null
|
||||||
|
? null
|
||||||
|
: Fragment$userFields.fromJson(
|
||||||
|
json['getUser'] as Map<String, dynamic>),
|
||||||
|
$__typename: json['__typename'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Query$GetUser$usersToJson(
|
||||||
|
Query$GetUser$users instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'getUser': instance.getUser?.toJson(),
|
||||||
|
'__typename': instance.$__typename,
|
||||||
|
};
|
||||||
|
|
||||||
Variables$Mutation$CreateUser _$Variables$Mutation$CreateUserFromJson(
|
Variables$Mutation$CreateUser _$Variables$Mutation$CreateUserFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
Variables$Mutation$CreateUser(
|
Variables$Mutation$CreateUser(
|
||||||
|
@ -60,8 +156,7 @@ Mutation$CreateUser$createUser _$Mutation$CreateUser$createUserFromJson(
|
||||||
$__typename: json['__typename'] as String,
|
$__typename: json['__typename'] as String,
|
||||||
user: json['user'] == null
|
user: json['user'] == null
|
||||||
? null
|
? null
|
||||||
: Mutation$CreateUser$createUser$user.fromJson(
|
: Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||||
json['user'] as Map<String, dynamic>),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$CreateUser$createUserToJson(
|
Map<String, dynamic> _$Mutation$CreateUser$createUserToJson(
|
||||||
|
@ -74,287 +169,6 @@ Map<String, dynamic> _$Mutation$CreateUser$createUserToJson(
|
||||||
'user': instance.user?.toJson(),
|
'user': instance.user?.toJson(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Mutation$CreateUser$createUser$user
|
|
||||||
_$Mutation$CreateUser$createUser$userFromJson(Map<String, dynamic> json) =>
|
|
||||||
Mutation$CreateUser$createUser$user(
|
|
||||||
username: json['username'] as String,
|
|
||||||
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'],
|
|
||||||
unknownValue: Enum$UserType.$unknown),
|
|
||||||
sshKeys: (json['sshKeys'] as List<dynamic>)
|
|
||||||
.map((e) => e as String)
|
|
||||||
.toList(),
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$CreateUser$createUser$userToJson(
|
|
||||||
Mutation$CreateUser$createUser$user instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'username': instance.username,
|
|
||||||
'userType': _$Enum$UserTypeEnumMap[instance.userType]!,
|
|
||||||
'sshKeys': instance.sshKeys,
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
const _$Enum$UserTypeEnumMap = {
|
|
||||||
Enum$UserType.NORMAL: 'NORMAL',
|
|
||||||
Enum$UserType.PRIMARY: 'PRIMARY',
|
|
||||||
Enum$UserType.ROOT: 'ROOT',
|
|
||||||
Enum$UserType.$unknown: r'$unknown',
|
|
||||||
};
|
|
||||||
|
|
||||||
Query$AllUsers _$Query$AllUsersFromJson(Map<String, dynamic> json) =>
|
|
||||||
Query$AllUsers(
|
|
||||||
users:
|
|
||||||
Query$AllUsers$users.fromJson(json['users'] as Map<String, dynamic>),
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Query$AllUsersToJson(Query$AllUsers instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'users': instance.users.toJson(),
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Query$AllUsers$users _$Query$AllUsers$usersFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Query$AllUsers$users(
|
|
||||||
allUsers: (json['allUsers'] as List<dynamic>)
|
|
||||||
.map((e) =>
|
|
||||||
Query$AllUsers$users$allUsers.fromJson(e as Map<String, dynamic>))
|
|
||||||
.toList(),
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Query$AllUsers$usersToJson(
|
|
||||||
Query$AllUsers$users instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'allUsers': instance.allUsers.map((e) => e.toJson()).toList(),
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Query$AllUsers$users$allUsers _$Query$AllUsers$users$allUsersFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Query$AllUsers$users$allUsers(
|
|
||||||
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'],
|
|
||||||
unknownValue: Enum$UserType.$unknown),
|
|
||||||
username: json['username'] as String,
|
|
||||||
sshKeys:
|
|
||||||
(json['sshKeys'] as List<dynamic>).map((e) => e as String).toList(),
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Query$AllUsers$users$allUsersToJson(
|
|
||||||
Query$AllUsers$users$allUsers instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'userType': _$Enum$UserTypeEnumMap[instance.userType]!,
|
|
||||||
'username': instance.username,
|
|
||||||
'sshKeys': instance.sshKeys,
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Variables$Mutation$AddSshKey _$Variables$Mutation$AddSshKeyFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Variables$Mutation$AddSshKey(
|
|
||||||
sshInput: Input$SshMutationInput.fromJson(
|
|
||||||
json['sshInput'] as Map<String, dynamic>),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Variables$Mutation$AddSshKeyToJson(
|
|
||||||
Variables$Mutation$AddSshKey instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'sshInput': instance.sshInput.toJson(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Mutation$AddSshKey _$Mutation$AddSshKeyFromJson(Map<String, dynamic> json) =>
|
|
||||||
Mutation$AddSshKey(
|
|
||||||
addSshKey: Mutation$AddSshKey$addSshKey.fromJson(
|
|
||||||
json['addSshKey'] as Map<String, dynamic>),
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$AddSshKeyToJson(Mutation$AddSshKey instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'addSshKey': instance.addSshKey.toJson(),
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Mutation$AddSshKey$addSshKey _$Mutation$AddSshKey$addSshKeyFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Mutation$AddSshKey$addSshKey(
|
|
||||||
code: json['code'] as int,
|
|
||||||
message: json['message'] as String,
|
|
||||||
success: json['success'] as bool,
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
user: json['user'] == null
|
|
||||||
? null
|
|
||||||
: Mutation$AddSshKey$addSshKey$user.fromJson(
|
|
||||||
json['user'] as Map<String, dynamic>),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$AddSshKey$addSshKeyToJson(
|
|
||||||
Mutation$AddSshKey$addSshKey instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'code': instance.code,
|
|
||||||
'message': instance.message,
|
|
||||||
'success': instance.success,
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
'user': instance.user?.toJson(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Mutation$AddSshKey$addSshKey$user _$Mutation$AddSshKey$addSshKey$userFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Mutation$AddSshKey$addSshKey$user(
|
|
||||||
sshKeys:
|
|
||||||
(json['sshKeys'] as List<dynamic>).map((e) => e as String).toList(),
|
|
||||||
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'],
|
|
||||||
unknownValue: Enum$UserType.$unknown),
|
|
||||||
username: json['username'] as String,
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$AddSshKey$addSshKey$userToJson(
|
|
||||||
Mutation$AddSshKey$addSshKey$user instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'sshKeys': instance.sshKeys,
|
|
||||||
'userType': _$Enum$UserTypeEnumMap[instance.userType]!,
|
|
||||||
'username': instance.username,
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Variables$Query$GetUser _$Variables$Query$GetUserFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Variables$Query$GetUser(
|
|
||||||
username: json['username'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Variables$Query$GetUserToJson(
|
|
||||||
Variables$Query$GetUser instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'username': instance.username,
|
|
||||||
};
|
|
||||||
|
|
||||||
Query$GetUser _$Query$GetUserFromJson(Map<String, dynamic> json) =>
|
|
||||||
Query$GetUser(
|
|
||||||
users:
|
|
||||||
Query$GetUser$users.fromJson(json['users'] as Map<String, dynamic>),
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Query$GetUserToJson(Query$GetUser instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'users': instance.users.toJson(),
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Query$GetUser$users _$Query$GetUser$usersFromJson(Map<String, dynamic> json) =>
|
|
||||||
Query$GetUser$users(
|
|
||||||
getUser: json['getUser'] == null
|
|
||||||
? null
|
|
||||||
: Query$GetUser$users$getUser.fromJson(
|
|
||||||
json['getUser'] as Map<String, dynamic>),
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Query$GetUser$usersToJson(
|
|
||||||
Query$GetUser$users instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'getUser': instance.getUser?.toJson(),
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Query$GetUser$users$getUser _$Query$GetUser$users$getUserFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Query$GetUser$users$getUser(
|
|
||||||
sshKeys:
|
|
||||||
(json['sshKeys'] as List<dynamic>).map((e) => e as String).toList(),
|
|
||||||
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'],
|
|
||||||
unknownValue: Enum$UserType.$unknown),
|
|
||||||
username: json['username'] as String,
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Query$GetUser$users$getUserToJson(
|
|
||||||
Query$GetUser$users$getUser instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'sshKeys': instance.sshKeys,
|
|
||||||
'userType': _$Enum$UserTypeEnumMap[instance.userType]!,
|
|
||||||
'username': instance.username,
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Variables$Mutation$RemoveSshKey _$Variables$Mutation$RemoveSshKeyFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Variables$Mutation$RemoveSshKey(
|
|
||||||
sshInput: Input$SshMutationInput.fromJson(
|
|
||||||
json['sshInput'] as Map<String, dynamic>),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Variables$Mutation$RemoveSshKeyToJson(
|
|
||||||
Variables$Mutation$RemoveSshKey instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'sshInput': instance.sshInput.toJson(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Mutation$RemoveSshKey _$Mutation$RemoveSshKeyFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Mutation$RemoveSshKey(
|
|
||||||
removeSshKey: Mutation$RemoveSshKey$removeSshKey.fromJson(
|
|
||||||
json['removeSshKey'] as Map<String, dynamic>),
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$RemoveSshKeyToJson(
|
|
||||||
Mutation$RemoveSshKey instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'removeSshKey': instance.removeSshKey.toJson(),
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Mutation$RemoveSshKey$removeSshKey _$Mutation$RemoveSshKey$removeSshKeyFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Mutation$RemoveSshKey$removeSshKey(
|
|
||||||
code: json['code'] as int,
|
|
||||||
message: json['message'] as String,
|
|
||||||
success: json['success'] as bool,
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
user: json['user'] == null
|
|
||||||
? null
|
|
||||||
: Mutation$RemoveSshKey$removeSshKey$user.fromJson(
|
|
||||||
json['user'] as Map<String, dynamic>),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$RemoveSshKey$removeSshKeyToJson(
|
|
||||||
Mutation$RemoveSshKey$removeSshKey instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'code': instance.code,
|
|
||||||
'message': instance.message,
|
|
||||||
'success': instance.success,
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
'user': instance.user?.toJson(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Mutation$RemoveSshKey$removeSshKey$user
|
|
||||||
_$Mutation$RemoveSshKey$removeSshKey$userFromJson(
|
|
||||||
Map<String, dynamic> json) =>
|
|
||||||
Mutation$RemoveSshKey$removeSshKey$user(
|
|
||||||
sshKeys: (json['sshKeys'] as List<dynamic>)
|
|
||||||
.map((e) => e as String)
|
|
||||||
.toList(),
|
|
||||||
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'],
|
|
||||||
unknownValue: Enum$UserType.$unknown),
|
|
||||||
username: json['username'] as String,
|
|
||||||
$__typename: json['__typename'] as String,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$RemoveSshKey$removeSshKey$userToJson(
|
|
||||||
Mutation$RemoveSshKey$removeSshKey$user instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'sshKeys': instance.sshKeys,
|
|
||||||
'userType': _$Enum$UserTypeEnumMap[instance.userType]!,
|
|
||||||
'username': instance.username,
|
|
||||||
'__typename': instance.$__typename,
|
|
||||||
};
|
|
||||||
|
|
||||||
Variables$Mutation$DeleteUser _$Variables$Mutation$DeleteUserFromJson(
|
Variables$Mutation$DeleteUser _$Variables$Mutation$DeleteUserFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
Variables$Mutation$DeleteUser(
|
Variables$Mutation$DeleteUser(
|
||||||
|
@ -435,8 +249,7 @@ Mutation$UpdateUser$updateUser _$Mutation$UpdateUser$updateUserFromJson(
|
||||||
$__typename: json['__typename'] as String,
|
$__typename: json['__typename'] as String,
|
||||||
user: json['user'] == null
|
user: json['user'] == null
|
||||||
? null
|
? null
|
||||||
: Mutation$UpdateUser$updateUser$user.fromJson(
|
: Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||||
json['user'] as Map<String, dynamic>),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$UpdateUser$updateUserToJson(
|
Map<String, dynamic> _$Mutation$UpdateUser$updateUserToJson(
|
||||||
|
@ -449,23 +262,100 @@ Map<String, dynamic> _$Mutation$UpdateUser$updateUserToJson(
|
||||||
'user': instance.user?.toJson(),
|
'user': instance.user?.toJson(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Mutation$UpdateUser$updateUser$user
|
Variables$Mutation$AddSshKey _$Variables$Mutation$AddSshKeyFromJson(
|
||||||
_$Mutation$UpdateUser$updateUser$userFromJson(Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
Mutation$UpdateUser$updateUser$user(
|
Variables$Mutation$AddSshKey(
|
||||||
sshKeys: (json['sshKeys'] as List<dynamic>)
|
sshInput: Input$SshMutationInput.fromJson(
|
||||||
.map((e) => e as String)
|
json['sshInput'] as Map<String, dynamic>),
|
||||||
.toList(),
|
);
|
||||||
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'],
|
|
||||||
unknownValue: Enum$UserType.$unknown),
|
Map<String, dynamic> _$Variables$Mutation$AddSshKeyToJson(
|
||||||
username: json['username'] as String,
|
Variables$Mutation$AddSshKey instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'sshInput': instance.sshInput.toJson(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Mutation$AddSshKey _$Mutation$AddSshKeyFromJson(Map<String, dynamic> json) =>
|
||||||
|
Mutation$AddSshKey(
|
||||||
|
addSshKey: Mutation$AddSshKey$addSshKey.fromJson(
|
||||||
|
json['addSshKey'] as Map<String, dynamic>),
|
||||||
$__typename: json['__typename'] as String,
|
$__typename: json['__typename'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$Mutation$UpdateUser$updateUser$userToJson(
|
Map<String, dynamic> _$Mutation$AddSshKeyToJson(Mutation$AddSshKey instance) =>
|
||||||
Mutation$UpdateUser$updateUser$user instance) =>
|
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'sshKeys': instance.sshKeys,
|
'addSshKey': instance.addSshKey.toJson(),
|
||||||
'userType': _$Enum$UserTypeEnumMap[instance.userType]!,
|
|
||||||
'username': instance.username,
|
|
||||||
'__typename': instance.$__typename,
|
'__typename': instance.$__typename,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Mutation$AddSshKey$addSshKey _$Mutation$AddSshKey$addSshKeyFromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
Mutation$AddSshKey$addSshKey(
|
||||||
|
code: json['code'] as int,
|
||||||
|
message: json['message'] as String,
|
||||||
|
success: json['success'] as bool,
|
||||||
|
$__typename: json['__typename'] as String,
|
||||||
|
user: json['user'] == null
|
||||||
|
? null
|
||||||
|
: Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Mutation$AddSshKey$addSshKeyToJson(
|
||||||
|
Mutation$AddSshKey$addSshKey instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'code': instance.code,
|
||||||
|
'message': instance.message,
|
||||||
|
'success': instance.success,
|
||||||
|
'__typename': instance.$__typename,
|
||||||
|
'user': instance.user?.toJson(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Variables$Mutation$RemoveSshKey _$Variables$Mutation$RemoveSshKeyFromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
Variables$Mutation$RemoveSshKey(
|
||||||
|
sshInput: Input$SshMutationInput.fromJson(
|
||||||
|
json['sshInput'] as Map<String, dynamic>),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Variables$Mutation$RemoveSshKeyToJson(
|
||||||
|
Variables$Mutation$RemoveSshKey instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'sshInput': instance.sshInput.toJson(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Mutation$RemoveSshKey _$Mutation$RemoveSshKeyFromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
Mutation$RemoveSshKey(
|
||||||
|
removeSshKey: Mutation$RemoveSshKey$removeSshKey.fromJson(
|
||||||
|
json['removeSshKey'] as Map<String, dynamic>),
|
||||||
|
$__typename: json['__typename'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Mutation$RemoveSshKeyToJson(
|
||||||
|
Mutation$RemoveSshKey instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'removeSshKey': instance.removeSshKey.toJson(),
|
||||||
|
'__typename': instance.$__typename,
|
||||||
|
};
|
||||||
|
|
||||||
|
Mutation$RemoveSshKey$removeSshKey _$Mutation$RemoveSshKey$removeSshKeyFromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
Mutation$RemoveSshKey$removeSshKey(
|
||||||
|
code: json['code'] as int,
|
||||||
|
message: json['message'] as String,
|
||||||
|
success: json['success'] as bool,
|
||||||
|
$__typename: json['__typename'] as String,
|
||||||
|
user: json['user'] == null
|
||||||
|
? null
|
||||||
|
: Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$Mutation$RemoveSshKey$removeSshKeyToJson(
|
||||||
|
Mutation$RemoveSshKey$removeSshKey instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'code': instance.code,
|
||||||
|
'message': instance.message,
|
||||||
|
'success': instance.success,
|
||||||
|
'__typename': instance.$__typename,
|
||||||
|
'user': instance.user?.toJson(),
|
||||||
|
};
|
||||||
|
|
|
@ -6,7 +6,9 @@ import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_settings.g
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_api.graphql.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_api.graphql.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/disk_volumes.graphql.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/disk_volumes.graphql.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/services.graphql.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/services.graphql.dart';
|
||||||
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/users.graphql.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/api_token.dart';
|
import 'package:selfprivacy/logic/models/json/api_token.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/server_disk_volume.dart';
|
import 'package:selfprivacy/logic/models/json/server_disk_volume.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
||||||
|
@ -16,6 +18,7 @@ part 'volume_api.dart';
|
||||||
part 'jobs_api.dart';
|
part 'jobs_api.dart';
|
||||||
part 'server_actions_api.dart';
|
part 'server_actions_api.dart';
|
||||||
part 'services_api.dart';
|
part 'services_api.dart';
|
||||||
|
part 'users_api.dart';
|
||||||
|
|
||||||
class GenericMutationResult {
|
class GenericMutationResult {
|
||||||
GenericMutationResult({
|
GenericMutationResult({
|
||||||
|
|
189
lib/logic/api_maps/graphql_maps/server_api/users_api.dart
Normal file
189
lib/logic/api_maps/graphql_maps/server_api/users_api.dart
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
part of 'server.dart';
|
||||||
|
|
||||||
|
class UserMutationResult extends GenericMutationResult {
|
||||||
|
UserMutationResult({
|
||||||
|
required final super.success,
|
||||||
|
required final super.code,
|
||||||
|
final super.message,
|
||||||
|
this.user,
|
||||||
|
});
|
||||||
|
final User? user;
|
||||||
|
}
|
||||||
|
|
||||||
|
mixin UsersApi on ApiMap {
|
||||||
|
Future<List<User>> getAllUsers() async {
|
||||||
|
QueryResult<Query$AllUsers> response;
|
||||||
|
List<User> users = [];
|
||||||
|
try {
|
||||||
|
final GraphQLClient client = await getClient();
|
||||||
|
response = await client.query$AllUsers();
|
||||||
|
if (response.hasException) {
|
||||||
|
print(response.exception.toString());
|
||||||
|
}
|
||||||
|
users = response.parsedData?.users.allUsers.map<User>((final user) => User.fromGraphQL(user)).toList() ?? [];
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<User?> getUser(final String login) async {
|
||||||
|
QueryResult<Query$GetUser> response;
|
||||||
|
User? user;
|
||||||
|
try {
|
||||||
|
final GraphQLClient client = await getClient();
|
||||||
|
final variables = Variables$Query$GetUser(username: login);
|
||||||
|
response = await client.query$GetUser(Options$Query$GetUser(variables: variables));
|
||||||
|
if (response.hasException) {
|
||||||
|
print(response.exception.toString());
|
||||||
|
}
|
||||||
|
if (response.parsedData?.users.getUser != null) {
|
||||||
|
user = User(
|
||||||
|
login: response.parsedData!.users.getUser!.username,
|
||||||
|
sshKeys: response.parsedData!.users.getUser?.sshKeys ?? const [],
|
||||||
|
isFoundOnServer: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<UserMutationResult> createUser(
|
||||||
|
final String username,
|
||||||
|
final String password,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
final GraphQLClient client = await getClient();
|
||||||
|
final variables = Variables$Mutation$CreateUser(
|
||||||
|
user: Input$UserMutationInput(username: username, password: password),
|
||||||
|
);
|
||||||
|
final mutation = Options$Mutation$CreateUser(variables: variables);
|
||||||
|
final response = await client.mutate$CreateUser(mutation);
|
||||||
|
return UserMutationResult(
|
||||||
|
success: response.parsedData?.createUser.success ?? false,
|
||||||
|
code: response.parsedData?.createUser.code ?? 500,
|
||||||
|
message: response.parsedData?.createUser.message,
|
||||||
|
user: response.parsedData?.createUser.user != null ? User.fromGraphQL(response.parsedData!.createUser.user!) : null,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
return UserMutationResult(
|
||||||
|
success: false,
|
||||||
|
code: 0,
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<GenericMutationResult> deleteUser(
|
||||||
|
final String username,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
final GraphQLClient client = await getClient();
|
||||||
|
final variables = Variables$Mutation$DeleteUser(username: username);
|
||||||
|
final mutation = Options$Mutation$DeleteUser(variables: variables);
|
||||||
|
final response = await client.mutate$DeleteUser(mutation);
|
||||||
|
return GenericMutationResult(
|
||||||
|
success: response.parsedData?.deleteUser.success ?? false,
|
||||||
|
code: response.parsedData?.deleteUser.code ?? 500,
|
||||||
|
message: response.parsedData?.deleteUser.message,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
return GenericMutationResult(
|
||||||
|
success: false,
|
||||||
|
code: 500,
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<UserMutationResult> updateUser(
|
||||||
|
final String username,
|
||||||
|
final String password,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
final GraphQLClient client = await getClient();
|
||||||
|
final variables = Variables$Mutation$UpdateUser(
|
||||||
|
user: Input$UserMutationInput(username: username, password: password),
|
||||||
|
);
|
||||||
|
final mutation = Options$Mutation$UpdateUser(variables: variables);
|
||||||
|
final response = await client.mutate$UpdateUser(mutation);
|
||||||
|
return UserMutationResult(
|
||||||
|
success: response.parsedData?.updateUser.success ?? false,
|
||||||
|
code: response.parsedData?.updateUser.code ?? 500,
|
||||||
|
message: response.parsedData?.updateUser.message,
|
||||||
|
user: response.parsedData?.updateUser.user != null ? User.fromGraphQL(response.parsedData!.updateUser.user!) : null,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
return UserMutationResult(
|
||||||
|
success: false,
|
||||||
|
code: 0,
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<UserMutationResult> addSshKey(
|
||||||
|
final String username,
|
||||||
|
final String sshKey,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
final GraphQLClient client = await getClient();
|
||||||
|
final variables = Variables$Mutation$AddSshKey(
|
||||||
|
sshInput: Input$SshMutationInput(
|
||||||
|
username: username,
|
||||||
|
sshKey: sshKey,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final mutation = Options$Mutation$AddSshKey(variables: variables);
|
||||||
|
final response = await client.mutate$AddSshKey(mutation);
|
||||||
|
return UserMutationResult(
|
||||||
|
success: response.parsedData?.addSshKey.success ?? false,
|
||||||
|
code: response.parsedData?.addSshKey.code ?? 500,
|
||||||
|
message: response.parsedData?.addSshKey.message,
|
||||||
|
user: response.parsedData?.addSshKey.user != null ? User.fromGraphQL(response.parsedData!.addSshKey.user!) : null,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
return UserMutationResult(
|
||||||
|
success: false,
|
||||||
|
code: 0,
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<UserMutationResult> removeSshKey(
|
||||||
|
final String username,
|
||||||
|
final String sshKey,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
final GraphQLClient client = await getClient();
|
||||||
|
final variables = Variables$Mutation$RemoveSshKey(
|
||||||
|
sshInput: Input$SshMutationInput(
|
||||||
|
username: username,
|
||||||
|
sshKey: sshKey,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final mutation = Options$Mutation$RemoveSshKey(variables: variables);
|
||||||
|
final response = await client.mutate$RemoveSshKey(mutation);
|
||||||
|
return UserMutationResult(
|
||||||
|
success: response.parsedData?.removeSshKey.success ?? false,
|
||||||
|
code: response.parsedData?.removeSshKey.code ?? 500,
|
||||||
|
message: response.parsedData?.removeSshKey.message,
|
||||||
|
user: response.parsedData?.removeSshKey.user != null ? User.fromGraphQL(response.parsedData!.removeSshKey.user!) : null,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
return UserMutationResult(
|
||||||
|
success: false,
|
||||||
|
code: 0,
|
||||||
|
message: e.toString(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ import 'dart:ui';
|
||||||
|
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/users.graphql.dart';
|
||||||
import 'package:selfprivacy/utils/color_utils.dart';
|
import 'package:selfprivacy/utils/color_utils.dart';
|
||||||
|
|
||||||
part 'user.g.dart';
|
part 'user.g.dart';
|
||||||
|
@ -16,6 +17,13 @@ class User extends Equatable {
|
||||||
this.note,
|
this.note,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
User.fromGraphQL(final Fragment$userFields user)
|
||||||
|
: this(
|
||||||
|
login: user.username,
|
||||||
|
sshKeys: user.sshKeys,
|
||||||
|
isFoundOnServer: true,
|
||||||
|
);
|
||||||
|
|
||||||
@HiveField(0)
|
@HiveField(0)
|
||||||
final String login;
|
final String login;
|
||||||
|
|
||||||
|
@ -37,6 +45,5 @@ class User extends Equatable {
|
||||||
Color get color => stringToColor(login);
|
Color get color => stringToColor(login);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() =>
|
String toString() => '$login, ${isFoundOnServer ? 'found' : 'not found'}, ${sshKeys.length} ssh keys, note: $note';
|
||||||
'$login, ${isFoundOnServer ? 'found' : 'not found'}, ${sshKeys.length} ssh keys, note: $note';
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue