class DatahubProject
Public Class Methods
new(datahub_http_client, project_name)
click to toggle source
# File lib/fluent/plugin/datahub/datahub-project.rb, line 5 def initialize(datahub_http_client, project_name) @client = datahub_http_client @project_name = project_name end
Public Instance Methods
create_topic(topic_name, shard_count, lifecycle, record_type, record_schema, comment)
click to toggle source
# File lib/fluent/plugin/datahub/datahub-project.rb, line 23 def create_topic(topic_name, shard_count, lifecycle, record_type, record_schema, comment) @client.create_topic(@project_name, topic_name, shard_count, lifecycle, record_type, record_schema, comment) return self.get_topic(topic_name) end
delete_topic(topic_name)
click to toggle source
# File lib/fluent/plugin/datahub/datahub-project.rb, line 32 def delete_topic(topic_name) @client.delete_topic(@project_name, topic_name) end
get_topic(topic_name)
click to toggle source
# File lib/fluent/plugin/datahub/datahub-project.rb, line 36 def get_topic(topic_name) result_map = @client.get_topic(@project_name, topic_name) record_schema_string = result_map["RecordSchema"] record_schema_map = JSON.parse(record_schema_string) fields = record_schema_map["fields"] record_schema = RecordSchema.new() for i in 0...fields.size field = fields[i] record_field = RecordField.new(field["name"], field["type"]) record_schema.add_field(record_field) end topic = DatahubTopic.new(@client, @project_name, topic_name) topic.shard_count = result_map["ShardCount"] topic.lifecycle = result_map["Lifecycle"] topic.record_type = result_map["RecordType"] topic.record_schema = record_schema topic.comment = result_map["Comment"] topic.create_time = result_map["CreateTime"] topic.last_modify_time = result_map["LastModifyTime"] return topic end
list_topics()
click to toggle source
# File lib/fluent/plugin/datahub/datahub-project.rb, line 10 def list_topics() topics_map = @client.list_topics topics_array = topics_map["TopicNames"] topics = [] for i in 0...topics_array.size topic_name = topics_array[i] topic = DatahubTopic.new(datahub_http_client, @project_name, topic_name) topics.push(topic) end return topics end
update_topic(topic_name, lifecycle, desc)
click to toggle source
# File lib/fluent/plugin/datahub/datahub-project.rb, line 28 def update_topic(topic_name, lifecycle, desc) @client.update_topic(@project_name, topic_name, lifecycle, desc) end