Class: Hivehook::Resources::APIKeyService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/hivehook/resources/api_key_service.rb

Constant Summary collapse

FRAGMENT =
"id name keyPrefix scopes sourceIds createdAt expiresAt revokedAt lastUsedAt"

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Hivehook::Resources::BaseService

Instance Method Details

#create(input) ⇒ Object



23
24
25
26
# File 'lib/hivehook/resources/api_key_service.rb', line 23

def create(input)
  query = "mutation($input: CreateAPIKeyInput!) { createAPIKey(input: $input) { apiKey { #{FRAGMENT} } rawKey } }"
  @transport.execute(query, { "input" => input })["createAPIKey"]
end

#get(id) ⇒ Object



18
19
20
21
# File 'lib/hivehook/resources/api_key_service.rb', line 18

def get(id)
  query = "query($id: UUID!) { apiKey(id: $id) { #{FRAGMENT} } }"
  @transport.execute(query, { "id" => id })["apiKey"]
end

#list(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/hivehook/resources/api_key_service.rb', line 8

def list(options = {})
  query = "query($search: String, $limit: Int, $offset: Int) {
    apiKeys(search: $search, limit: $limit, offset: $offset) {
      nodes { #{FRAGMENT} }
      pageInfo { total limit offset endCursor hasNextPage }
    }
  }"
  @transport.execute(query, build_variables(options, %w[search limit offset]))["apiKeys"]
end

#revoke(id) ⇒ Object



28
29
30
31
# File 'lib/hivehook/resources/api_key_service.rb', line 28

def revoke(id)
  query = "mutation($id: UUID!) { revokeAPIKey(id: $id) }"
  @transport.execute(query, { "id" => id })["revokeAPIKey"]
end