Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elastic-workplace-search

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elastic-workplace-search

  • 0.4.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

CircleCI build

A first-party Ruby client for Elastic Workplace Search.

Contents


Getting started 🐣

To install the gem, execute:

gem install elastic-workplace-search

Or place gem 'elastic-workplace-search', '~> 0.4.1 in your Gemfile and run bundle install.

Usage

Create a new instance of the Elastic Workplace Search client with your access token:

Elastic::WorkplaceSearch.access_token = '' # your access token
client = Elastic::WorkplaceSearch::Client.new

Change API endpoint

client = Elastic::WorkplaceSearch::Client.new
Elastic::WorkplaceSearch.endpoint = 'https://your-server.example.com/api/ws/v1'

Specifying an HTTP Proxy

client = Elastic::WorkplaceSearch::Client.new(:proxy => 'http://localhost:8888')

Documents

Indexing Documents

This example shows how to use the index_documents method:

content_source_key = '' # your content source key
documents = [
  {
    'id' => 'INscMGmhmX4',
    'url' => 'http://www.youtube.com/watch?v=v1uyQZNg2vE',
    'title' => 'The Original Grumpy Cat',
    'body' => 'this is a test'
  },
  {
    'id' => 'JNDFojsd02',
    'url' => 'http://www.youtube.com/watch?v=tsdfhk2j',
    'title' => 'Another Grumpy Cat',
    'body' => 'this is also a test'
  }
]

begin
  document_receipts = client.index_documents(content_source_key, documents)
  # handle results
rescue Elastic::WorkplaceSearch::ClientException => e
  # handle error
end
Destroying Documents
content_source_key = '' # your content source key
document_ids = ['INscMGmhmX4', 'JNDFojsd02']

begin
  destroy_document_results = client.destroy_documents(content_source_key, document_ids)
  # handle destroy document results
rescue Elastic::WorkplaceSearch::ClientException => e
  # handle error
end

Permissions

Listing all permissions
content_source_key = '' # your content source key

client.list_all_permissions(content_source_key)
Listing all permissions with paging
content_source_key = '' # your content source key

client.list_all_permissions(content_source_key, :current => 2, :size => 20)
Retrieve a User's permissions
content_source_key = '' # your content source key
user = 'enterprise_search'

client.get_user_permissions(content_source_key, user)
Add permissions to a User
content_source_key = '' # your content source key
user = 'enterprise_search'
permissions = ['permission1']

client.add_user_permissions(content_source_key, user, :permissions => permissions)
Update a User's permissions
content_source_key = '' # your content source key
user = 'enterprise_search'
permissions = ['permission2']

client.update_user_permissions(content_source_key, user, :permissions => permissions)
Remove permissions from a User
content_source_key = '' # your content source key
user = 'enterprise_search'
permissions = ['permission2']

client.remove_user_permissions(content_source_key, user, :permissions => permissions)

Running tests

Run tests via rspec:

$ ENDPOINT=http://localhost:3002/api/ws/v1 bundle exec rspec

FAQ 🔮

Where do I report issues with the client?

If something is not working as expected, please open an issue.

Contribute 🚀

We welcome contributors to the project. Before you begin, a couple notes...

License 📗

Apache 2.0 © Elastic

Thank you to all the contributors!

FAQs

Package last updated on 20 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc