Class: SearchKit::CLI::Documents
- Defined in:
- lib/search_kit/cli/documents.rb
Instance Method Summary collapse
- #create(slug, document) ⇒ Object
- #delete(slug, id) ⇒ Object
- #show(slug, id) ⇒ Object
- #update(slug, id, document) ⇒ Object
Methods inherited from Thor
Instance Method Details
#create(slug, document) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/search_kit/cli/documents.rb', line 22 def create(slug, document) document = JSON.parse(document, symbolize_names: true) response = client.create(slug, document) .info response.to_json rescue Errors::IndexNotFound .not_found rescue Errors::BadRequest .bad_request rescue Errors::Unprocessable .unprocessable rescue Faraday::ConnectionFailed .no_service rescue JSON::ParserError .json_parse_error end |
#delete(slug, id) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/search_kit/cli/documents.rb', line 39 def delete(slug, id) response = client.delete(slug, id) .info response.to_json rescue Errors::IndexNotFound .not_found rescue Faraday::ConnectionFailed .no_service end |
#show(slug, id) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/search_kit/cli/documents.rb', line 49 def show(slug, id) response = client.show(slug, id) .info response.to_json rescue Errors::IndexNotFound .not_found rescue Faraday::ConnectionFailed .no_service end |
#update(slug, id, document) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/search_kit/cli/documents.rb', line 59 def update(slug, id, document) document = JSON.parse(document, symbolize_names: true) response = client.update(slug, id, document) .info response.to_json rescue JSON::ParserError .json_parse_error rescue Errors::BadRequest .bad_request rescue Errors::IndexNotFound .not_found rescue Errors::Unprocessable .unprocessable rescue Faraday::ConnectionFailed .no_service end |