Class: Svix::StreamingSink

Inherits:
Object
  • Object
show all
Defined in:
lib/svix/api/streaming_sink.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ StreamingSink

Returns a new instance of StreamingSink.



9
10
11
12
# File 'lib/svix/api/streaming_sink.rb', line 9

def initialize(client)
  @client = client
  @transformation = StreamingSinkTransformation.new(client)
end

Instance Attribute Details

#transformationObject

Returns the value of attribute transformation.



8
9
10
# File 'lib/svix/api/streaming_sink.rb', line 8

def transformation
  @transformation
end

Instance Method Details

#create(stream_id, stream_sink_in, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/svix/api/streaming_sink.rb', line 28

def create(stream_id, stream_sink_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/stream/#{stream_id}/sink",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: stream_sink_in
  )
  StreamSinkOut.deserialize(res)
end

#delete(stream_id, sink_id) ⇒ Object



58
59
60
61
62
63
# File 'lib/svix/api/streaming_sink.rb', line 58

def delete(stream_id, sink_id)
  @client.execute_request(
    "DELETE",
    "/api/v1/stream/#{stream_id}/sink/#{sink_id}"
  )
end

#get(stream_id, sink_id) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/svix/api/streaming_sink.rb', line 41

def get(stream_id, sink_id)
  res = @client.execute_request(
    "GET",
    "/api/v1/stream/#{stream_id}/sink/#{sink_id}"
  )
  StreamSinkOut.deserialize(res)
end

#get_secret(stream_id, sink_id) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/svix/api/streaming_sink.rb', line 74

def get_secret(stream_id, sink_id)
  res = @client.execute_request(
    "GET",
    "/api/v1/stream/#{stream_id}/sink/#{sink_id}/secret"
  )
  SinkSecretOut.deserialize(res)
end

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



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/svix/api/streaming_sink.rb', line 14

def list(stream_id, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "GET",
    "/api/v1/stream/#{stream_id}/sink",
    query_params: {
      "limit" => options["limit"],
      "iterator" => options["iterator"],
      "order" => options["order"]
    }
  )
  ListResponseStreamSinkOut.deserialize(res)
end

#patch(stream_id, sink_id, stream_sink_patch) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/svix/api/streaming_sink.rb', line 65

def patch(stream_id, sink_id, stream_sink_patch)
  res = @client.execute_request(
    "PATCH",
    "/api/v1/stream/#{stream_id}/sink/#{sink_id}",
    body: stream_sink_patch
  )
  StreamSinkOut.deserialize(res)
end

#rotate_secret(stream_id, sink_id, endpoint_secret_rotate_in, options = {}) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/svix/api/streaming_sink.rb', line 82

def rotate_secret(stream_id, sink_id, endpoint_secret_rotate_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/stream/#{stream_id}/sink/#{sink_id}/secret/rotate",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: endpoint_secret_rotate_in
  )
  EmptyResponse.deserialize(res)
end

#upsert(stream_id, sink_id, stream_sink_in) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/svix/api/streaming_sink.rb', line 49

def upsert(stream_id, sink_id, stream_sink_in)
  res = @client.execute_request(
    "PUT",
    "/api/v1/stream/#{stream_id}/sink/#{sink_id}",
    body: stream_sink_in
  )
  StreamSinkOut.deserialize(res)
end