// This file is @generated by ptolemy <3.

pub const USER_API_KEYS_QUERY: &'static str = r###"UserApiKeys"###;

pub const USER_WORKSPACES_QUERY: &'static str = r###"UserWorkspaces"###;

pub const SEARCH_USERS_QUERY: &'static str = r###"SearchUsers"###;

pub const WORKSPACE_USERS_QUERY: &'static str = r###"WorkspaceUsers"###;

pub const WORKSPACE_SERVICE_API_KEYS_QUERY: &'static str = r###"WorkspaceServiceApiKeys"###;

pub const ME_QUERY: &'static str = r###"Me"###;

pub const CREATE_USER_API_KEY_MUTATION: &'static str = r###"CreateUserApiKey"###;

pub const CREATE_USER_MUTATION: &'static str = r###"CreateUser"###;

pub const DELETE_USER_API_KEY_MUTATION: &'static str = r###"DeleteUserApiKey"###;

pub const DELETE_USER_MUTATION: &'static str = r###"DeleteUser"###;

pub const ADD_USER_TO_WORKSPACE_MUTATION: &'static str = r###"AddUserToWorkspace"###;

pub const CHANGE_WORKSPACE_USER_ROLE_MUTATION: &'static str = r###"ChangeWorkspaceUserRole"###;

pub const CREATE_SERVICE_API_KEY_MUTATION: &'static str = r###"CreateServiceApiKey"###;

pub const DELETE_SERVICE_API_KEY_MUTATION: &'static str = r###"DeleteServiceApiKey"###;

pub const CREATE_WORKSPACE_MUTATION: &'static str = r###"CreateWorkspace"###;

pub const REMOVE_USER_FROM_WORKSPACE_MUTATION: &'static str = r###"RemoveUserFromWorkspace"###;

pub const DELETE_WORKSPACE_MUTATION: &'static str = r###"DeleteWorkspace"###;

pub const QUERY: &'static str = r###"query UserApiKeys($userId: Uuid) {
  user(id: $userId) {
    userApiKeys {
      expiresAt
      id
      keyPreview
      name
      userId
    }
  }
}

query UserWorkspaces($userId: Uuid, $username: String) {
  user(id: $userId, username: $username) {
    workspaces {
      ...ReturnsWorkspace
      users(username: $username) {
        role
      }
    }
  }
}

query SearchUsers($username: String, $userId: Uuid) {
  user(username: $username, id: $userId) {
    ...ReturnsUser
  }
}

query WorkspaceUsers($workspaceId: Uuid, $workspaceName: String, $userId: Uuid, $username: String) {
  workspace(id: $workspaceId, name: $workspaceName) {
    users {
      role
      user(id: $userId, username: $username) {
        ...ReturnsUser
      }
    }
  }
}

query WorkspaceServiceApiKeys($workspaceId: Uuid) {
  workspace(id: $workspaceId) {
    serviceApiKeys {
      id
      expiresAt
      keyPreview
      name
      permissions
      workspaceId
    }
  }
}

query Me {
  me {
    ...ReturnsUser
  }
}

fragment ReturnsUser on User {
  displayName
  id
  isAdmin
  isSysadmin
  status
  username
}

fragment ReturnsWorkspace on Workspace {
  archived
  description
  id
  name
  createdAt
  updatedAt
}
"###;

pub const MUTATION: &'static str = r###"mutation CreateUserApiKey($name: String!, $durationDays: Int) {
  user {
    createUserApiKey(name: $name, durationDays: $durationDays) {
      apiKey {
        apiKey
      }
      ...Result
    }
  }
}

mutation CreateUser($username: String!, $password: String!, $isAdmin: Boolean!, $displayName: String) {
  user {
    create(
      userData: {username: $username, password: $password, isSysadmin: false, isAdmin: $isAdmin, displayName: $displayName}
    ) {
      ...Result
      user {
        ...ReturnsUser
      }
    }
  }
}

mutation DeleteUserApiKey($apiKeyId: Uuid!) {
  user {
    deleteUserApiKey(apiKeyId: $apiKeyId) {
      ...Result
    }
  }
}

mutation DeleteUser($userId: Uuid!) {
  user {
    delete(id: $userId) {
      ...Result
    }
  }
}

mutation AddUserToWorkspace($userId: Uuid!, $workspaceId: Uuid!, $role: WorkspaceRoleEnum!) {
  workspace {
    addUser(
      workspaceUser: {userId: $userId, workspaceId: $workspaceId, role: $role}
    ) {
      ...Result
    }
  }
}

mutation ChangeWorkspaceUserRole($role: WorkspaceRoleEnum!, $userId: Uuid!, $workspaceId: Uuid!) {
  workspace {
    changeWorkspaceUserRole(
      newRole: $role
      userId: $userId
      workspaceId: $workspaceId
    ) {
      ...Result
    }
  }
}

mutation CreateServiceApiKey($name: String!, $permission: ApiKeyPermissionEnum!, $workspaceId: Uuid!, $durationDays: Int) {
  workspace {
    createServiceApiKey(
      name: $name
      permission: $permission
      workspaceId: $workspaceId
      durationDays: $durationDays
    ) {
      ...Result
      apiKey {
        apiKey
      }
    }
  }
}

mutation DeleteServiceApiKey($apiKeyId: Uuid!, $workspaceId: Uuid!) {
  workspace {
    deleteServiceApiKey(apiKeyId: $apiKeyId, workspaceId: $workspaceId) {
      ...Result
    }
  }
}

mutation CreateWorkspace($name: String!, $description: String, $adminUserId: Uuid!) {
  workspace {
    create(
      workspaceData: {name: $name, description: $description}
      adminUserId: $adminUserId
    ) {
      ...Result
      workspace {
        ...ReturnsWorkspace
      }
    }
  }
}

mutation RemoveUserFromWorkspace($userId: Uuid!, $workspaceId: Uuid!) {
  workspace {
    removeUser(userId: $userId, workspaceId: $workspaceId) {
      ...Result
    }
  }
}

mutation DeleteWorkspace($workspaceId: Uuid!) {
  workspace {
    delete(workspaceId: $workspaceId) {
      ...Result
    }
  }
}

fragment ReturnsUser on User {
  displayName
  id
  isAdmin
  isSysadmin
  status
  username
}

fragment Result on GQLResult {
  error {
    field
    message
  }
  success
}

fragment ReturnsWorkspace on Workspace {
  id
  name
  description
  archived
  createdAt
  updatedAt
}
"###;

