Class: Mushikago::Mitsubachi::Client

Inherits:
Http::Client show all
Defined in:
lib/mushikago/mitsubachi/client.rb

Overview

Mitsubachiサービスを利用する

Examples:

client = Mushikago::Mitsubachi::Client.new(:api_key => '<api_key>', :secret_key => '<secret_key>')

client.project_create('project01')
client.script_deploy('project01', 'sample.rb', 'sample.rb')
client.http_fetch('project01', 'http://www.mushikago.org/', 'sample.rb')

APIキーをファイルから読み込む場合

Mushikago.config.load(YAML.load(File.read('config.yml')))
client = Mushikago::Mitsubachi::Client.new

Instance Attribute Summary

Attributes inherited from Http::Client

api_key, signer

Instance Method Summary (collapse)

Methods inherited from Http::Client

#initialize, #send_request

Constructor Details

This class inherits a constructor from Mushikago::Http::Client

Instance Method Details

- (Mushikago::Http::Response) http_fetch(project_name, url, script_name, options = {})

TODO http/fetchの説明

Examples:

client.http_fetch('project01', 'http://www.tombo.ne.jp/', 'sample.rb', :follow_redirect => true)

Parameters:

  • project_name (String)

    プロジェクト名

  • url (String)

    クロール対象のURL

  • script_name (String)

    スクレイピングスクリプトのパス

  • options (Hash) (defaults to: {})

    リクエストのオプション

Options Hash (options):

  • :method('GET') (String)

    HTTPリクエストメソッド

  • :entity_parameter (String)
  • :follow_redirect (Boolean)
  • :parameters (String)
  • :header_overwrite (String)

Returns:



117
118
119
120
# File 'lib/mushikago/mitsubachi/client.rb', line 117

def http_fetch project_name, url, script_name, options={}
  request = HttpFetchRequest.new(project_name, url, script_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) http_push(project_name, url, script_name, file_name, file_input_key, options = {})

TODO http/pushの説明

Examples:

client.http_push('project01', 'http://www.tombo.ne.jp/', 'sample.rb')

Parameters:

  • project_name (String)

    プロジェクト名

  • url (String)

    クロール対象のURL

  • script_name (String)

    スクレイピングスクリプトのパス

  • file_name (String)
  • file_input_key (String)
  • options (Hash) (defaults to: {})

    リクエストのオプション

Options Hash (options):

  • :entity_parameter (String)
  • :parameters (String)
  • :header_overwrite (String)
  • :mime_type (String)

Returns:



137
138
139
140
# File 'lib/mushikago/mitsubachi/client.rb', line 137

def http_push project_name, url, script_name, file_name, file_input_key, options={}
  request = HttpPushRequest.new(project_name, url, script_name, file_name, file_input_key, options)
  send_request(request)
end

- (Mushikago::Http::Response) project_create(project_name, options = {})

TODO project/createの説明

Examples:

client.project_create('project01', :stdout => true)

Parameters:

  • project_name (String)

    プロジェクト名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



24
25
26
27
# File 'lib/mushikago/mitsubachi/client.rb', line 24

def project_create project_name, options={}
  request = ProjectCreateRequest.new(project_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) project_delete(project_name, options = {})

TODO project/deleteの説明

Examples:

client.project_delete('project01')

Parameters:

  • project_name (String)

    プロジェクト名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



74
75
76
77
# File 'lib/mushikago/mitsubachi/client.rb', line 74

def project_delete project_name, options={}
  request = ProjectDeleteRequest.new(project_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) project_discontinue(project_name, options = {})

TODO project/discontinueの説明

Examples:

client.project_discontinue('project01')

Parameters:

  • project_name (String)

    プロジェクト名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



98
99
100
101
# File 'lib/mushikago/mitsubachi/client.rb', line 98

def project_discontinue project_name, options={}
  request = ProjectDiscontinueRequest.new(project_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) project_info(project_name, options = {})

TODO project/infoの説明

Examples:

client.project_info('project01')

Parameters:

  • project_name (String)

    プロジェクト名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



50
51
52
53
# File 'lib/mushikago/mitsubachi/client.rb', line 50

def project_info project_name, options={}
  request = ProjectInfoRequest.new(project_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) project_list(options = {})

TODO project/listの説明

Examples:

client.project_list

Parameters:

  • options (Hash) (defaults to: {})

    リクエストのオプション

Options Hash (options):

  • :limit (Integer)
  • :offset (Integer)
  • :filter (String)

Returns:



38
39
40
41
# File 'lib/mushikago/mitsubachi/client.rb', line 38

def project_list options={}
  request = ProjectListRequest.new(options)
  send_request(request)
end

- (Mushikago::Http::Response) project_queues(project_name, options = {})

TODO project/queuesの説明

Examples:

client.project_queues('project01')

Parameters:

  • project_name (String)

    プロジェクト名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



62
63
64
65
# File 'lib/mushikago/mitsubachi/client.rb', line 62

def project_queues project_name, options={}
  request = ProjectQueuesRequest.new(project_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) project_update(project_name, options = {})

TODO project/updateの説明

Examples:

client.project_update('project01', :stdout => false)

Parameters:

  • project_name (String)

    プロジェクト名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



86
87
88
89
# File 'lib/mushikago/mitsubachi/client.rb', line 86

def project_update project_name, options={}
  request = ProjectUpdateRequest.new(project_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) resource_delete(project_name, file_name, options = {})

TODO resource/deleteの説明

Examples:

client.resource_delete('project01', 'sample.rb')

Parameters:

  • project_name (String)

    プロジェクト名

  • file_name (String)

    保存先のファイル名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



249
250
251
252
# File 'lib/mushikago/mitsubachi/client.rb', line 249

def resource_delete project_name, file_name, options={}
  request = ResourceDeleteRequest.new(project_name, file_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) resource_get(project_name, file_name, options = {})

TODO resource/getの説明

Examples:

client.resource_get('project01', 'sample.rb')

Parameters:

  • project_name (String)

    プロジェクト名

  • file_name (String)

    保存先のファイル名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



236
237
238
239
# File 'lib/mushikago/mitsubachi/client.rb', line 236

def resource_get project_name, file_name, options={}
  request = ResourceGetRequest.new(project_name, file_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) resource_list(project_name, options = {})

TODO resource/listの説明

Examples:

client.resource_list('project01')

Parameters:

  • project_name (String)

    プロジェクト名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Options Hash (options):

  • :limit (Integer)
  • :offset (Integer)
  • :filter (String)

Returns:



223
224
225
226
# File 'lib/mushikago/mitsubachi/client.rb', line 223

def resource_list project_name, options={}
  request = ResourceListRequest.new(project_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) resource_store(project_name, file_or_file_name, options = {})

TODO resource/storeの説明

Examples:

client.resource_store('project01', 'sample.csv',)

Parameters:

  • project_name (String)

    プロジェクト名

  • file_or_file_name (String of File)

    デプロイするファイルオブジェクトもしくはファイルパス

  • options (Hash) (defaults to: {})

    リクエストのオプション

Options Hash (options):

  • :file_name (String)

    デプロイ先のファイル名

  • :content_type (String)
  • :public (public)

Returns:



208
209
210
211
# File 'lib/mushikago/mitsubachi/client.rb', line 208

def resource_store project_name, file_or_file_name, options={}
  request = ResourceStoreRequest.new(project_name, file_or_file_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) script_delete(project_name, script_name, options = {})

TODO script/deleteの説明

Examples:

client.script_delete('project01', 'sample.rb')

Parameters:

  • project_name (String)

    プロジェクト名

  • script_name (String)

    デプロイ先のファイル名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



192
193
194
195
# File 'lib/mushikago/mitsubachi/client.rb', line 192

def script_delete project_name, script_name, options={}
  request = ScriptDeleteRequest.new(project_name, script_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) script_deploy(project_name, file_or_file_name, options = {})

TODO script/deployの説明

Examples:

client.script_deploy('project01', 'sample.rb', :script_name => 'hoge.rb')

Parameters:

  • project_name (String)

    プロジェクト名

  • file_or_file_name (String of File)

    デプロイするファイルオブジェクトもしくはファイルパス

  • options (Hash) (defaults to: {})

    リクエストのオプション

Options Hash (options):

  • script_name (String)

    デプロイ先のファイル名

Returns:



151
152
153
154
# File 'lib/mushikago/mitsubachi/client.rb', line 151

def script_deploy project_name, file_or_file_name, options={}
  request = ScriptDeployRequest.new(project_name, file_or_file_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) script_get(project_name, script_name, options = {})

TODO script/getの説明

Examples:

client.script_get('project01', 'sample.rb')

Parameters:

  • project_name (String)

    プロジェクト名

  • script_name (String)

    デプロイ先のファイル名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Returns:



179
180
181
182
# File 'lib/mushikago/mitsubachi/client.rb', line 179

def script_get project_name, script_name, options={}
  request = ScriptGetRequest.new(project_name, script_name, options)
  send_request(request)
end

- (Mushikago::Http::Response) script_list(project_name, options = {})

TODO script/listの説明

Examples:

client.script_list('project01')

Parameters:

  • project_name (String)

    プロジェクト名

  • options (Hash) (defaults to: {})

    リクエストのオプション

Options Hash (options):

  • :limit (Integer)
  • :offset (Integer)
  • :filter (String)

Returns:



166
167
168
169
# File 'lib/mushikago/mitsubachi/client.rb', line 166

def script_list project_name, options={}
  request = ScriptListRequest.new(project_name, options)
  send_request(request)
end