Class: Hivehook::Resources::StreamSinkService

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

Constant Summary collapse

FRAGMENT =
"id streamId name sinkType config batchSize flushInterval cursorSequence status lastFlushedAt createdAt"

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



24
25
26
27
# File 'lib/hivehook/resources/stream_sink_service.rb', line 24

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

#delete(id) ⇒ Object



34
35
36
37
# File 'lib/hivehook/resources/stream_sink_service.rb', line 34

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

#get(id) ⇒ Object



19
20
21
22
# File 'lib/hivehook/resources/stream_sink_service.rb', line 19

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

#list(stream_id, options = {}) ⇒ Object



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

def list(stream_id, options = {})
  query = "query($streamId: UUID!, $status: SinkStatus, $search: String, $limit: Int, $offset: Int, $after: String, $first: Int) {
    streamSinks(streamId: $streamId, status: $status, search: $search, limit: $limit, offset: $offset, after: $after, first: $first) {
      nodes { #{FRAGMENT} }
      pageInfo { total limit offset endCursor hasNextPage }
    }
  }"
  vars = { "streamId" => stream_id }.merge(build_variables(options, %w[status search limit offset after first]))
  @transport.execute(query, vars)["streamSinks"]
end

#update(id, input) ⇒ Object



29
30
31
32
# File 'lib/hivehook/resources/stream_sink_service.rb', line 29

def update(id, input)
  query = "mutation($id: UUID!, $input: UpdateStreamSinkInput!) { updateStreamSink(id: $id, input: $input) { #{FRAGMENT} } }"
  @transport.execute(query, { "id" => id, "input" => input })["updateStreamSink"]
end