# GraphQL Schema

```graphql
scalar DateTime
scalar JSON

type Query {
  health: HealthStatus
  resources(filter: ResourceFilter): [Resource!]!
  resource(id: ID!): Resource
  sites: [Site!]!
  site(id: ID!): Site
  me: User
  users: [User!]!
  user(id: ID!): User
}

type Mutation {
  login(email: String!, password: String!): AuthPayload!
  logout: Boolean!
  createResource(input: CreateResourceInput!): Resource!
  updateResource(id: ID!, input: UpdateResourceInput!): Resource!
  deleteResource(id: ID!): Boolean!
  createUser(input: CreateUserInput!): User!
  updateUser(id: ID!, input: UpdateUserInput!): User!
  deleteUser(id: ID!): Boolean!
}

type Subscription {
  resourceUpdated(id: ID!): Resource!
  resourceCreated: Resource!
  resourceDeleted(id: ID!): ID!
}

type HealthStatus {
  status: String!
  timestamp: DateTime!
  version: String!
}

type Resource {
  id: ID!
  name: String!
  type: ResourceType!
  status: ResourceStatus!
  site: Site!
  metadata: JSON
  createdAt: DateTime!
  updatedAt: DateTime!
}

type Site {
  id: ID!
  name: String!
  region: String!
  status: SiteStatus!
  resources: [Resource!]!
  createdAt: DateTime!
  updatedAt: DateTime!
}

type User {
  id: ID!
  email: String!
  name: String!
  role: UserRole!
  createdAt: DateTime!
  updatedAt: DateTime!
}

type AuthPayload {
  token: String!
  user: User!
}

enum ResourceType {
  VM
  CONTAINER
  STORAGE
  NETWORK
}

enum ResourceStatus {
  PENDING
  PROVISIONING
  RUNNING
  STOPPED
  ERROR
  DELETING
}

enum SiteStatus {
  ACTIVE
  INACTIVE
  MAINTENANCE
}

enum UserRole {
  ADMIN
  USER
  VIEWER
}

input ResourceFilter {
  type: ResourceType
  status: ResourceStatus
  siteId: ID
}

input CreateResourceInput {
  name: String!
  type: ResourceType!
  siteId: ID!
  metadata: JSON
}

input UpdateResourceInput {
  name: String
  metadata: JSON
}

input CreateUserInput {
  email: String!
  name: String!
  password: String!
  role: UserRole
}

input UpdateUserInput {
  name: String
  role: UserRole
}
```

