Class: DatahubProject
- Inherits:
-
Object
- Object
- DatahubProject
- Defined in:
- lib/fluent/plugin/datahub/datahub-project.rb
Instance Method Summary collapse
- #create_topic(topic_name, shard_count, lifecycle, record_type, record_schema, comment) ⇒ Object
- #delete_topic(topic_name) ⇒ Object
- #get_topic(topic_name) ⇒ Object
-
#initialize(datahub_http_client, project_name) ⇒ DatahubProject
constructor
A new instance of DatahubProject.
- #list_topics ⇒ Object
- #update_topic(topic_name, lifecycle, desc) ⇒ Object
Constructor Details
#initialize(datahub_http_client, project_name) ⇒ DatahubProject
5 6 7 8 |
# 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 |
Instance Method Details
#create_topic(topic_name, shard_count, lifecycle, record_type, record_schema, comment) ⇒ Object
23 24 25 26 |
# 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) ⇒ Object
32 33 34 |
# 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) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# 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 ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# 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) ⇒ Object
28 29 30 |
# 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 |