Sha256: 6aa5088b49d4d7e45922e4f5f40c36d99ef938e68b573fb304b34bf6e30870fb

Contents?: true

Size: 1.79 KB

Versions: 22

Compression:

Stored size: 1.79 KB

Contents

require "seatsio/exception"
require "base64"
require "seatsio/httpClient"
require "seatsio/domain"
require "json"
require "cgi"

module Seatsio
  class WorkspacesClient

    def initialize(http_client)
      @http_client = http_client
    end

    def create(name:, is_test: nil)
      body = {}
      body['name'] = name
      body['isTest'] = is_test if is_test

      response = @http_client.post("workspaces", body)
      Workspace.new(response)
    end

    def update(key:, name:)
      body = {}
      body['name'] = name
      @http_client.post("workspaces/#{key}", body)
    end

    def regenerate_secret_key(key:)
      response = @http_client.post("workspaces/#{key}/actions/regenerate-secret-key")
      response['secretKey']
    end

    def activate(key:)
      @http_client.post("workspaces/#{key}/actions/activate")
    end

    def deactivate(key:)
      @http_client.post("workspaces/#{key}/actions/deactivate")
    end

    def set_default(key:)
      @http_client.post("workspaces/actions/set-default/#{key}")
    end

    def list(filter: nil)
      extended_cursor = cursor
      extended_cursor.set_query_param('filter', filter)
      extended_cursor
    end

    def active(filter: nil)
      extended_cursor = Pagination::Cursor.new(Workspace, 'workspaces/active', @http_client)
      extended_cursor.set_query_param('filter', filter)
      extended_cursor
    end

    def inactive(filter: nil)
      extended_cursor = Pagination::Cursor.new(Workspace, 'workspaces/inactive', @http_client)
      extended_cursor.set_query_param('filter', filter)
      extended_cursor
    end

    def retrieve(key:)
      response = @http_client.get("workspaces/#{key}")
      Workspace.new(response)
    end

    private

    def cursor()
      Pagination::Cursor.new(Workspace, 'workspaces', @http_client)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
seatsio-51.4.0 lib/seatsio/workspaces.rb
seatsio-51.3.0 lib/seatsio/workspaces.rb
seatsio-51.2.0 lib/seatsio/workspaces.rb
seatsio-51.1.0 lib/seatsio/workspaces.rb
seatsio-51.0.0 lib/seatsio/workspaces.rb
seatsio-50.0.0 lib/seatsio/workspaces.rb
seatsio-49.1.0 lib/seatsio/workspaces.rb
seatsio-49.0.0 lib/seatsio/workspaces.rb
seatsio-48.11.0 lib/seatsio/workspaces.rb
seatsio-48.10.0 lib/seatsio/workspaces.rb
seatsio-48.9.0 lib/seatsio/workspaces.rb
seatsio-48.8.0 lib/seatsio/workspaces.rb
seatsio-48.7.0 lib/seatsio/workspaces.rb
seatsio-48.6.0 lib/seatsio/workspaces.rb
seatsio-48.5.0 lib/seatsio/workspaces.rb
seatsio-48.4.0 lib/seatsio/workspaces.rb
seatsio-48.3.0 lib/seatsio/workspaces.rb
seatsio-48.2.0 lib/seatsio/workspaces.rb
seatsio-48.1.0 lib/seatsio/workspaces.rb
seatsio-48.0.0 lib/seatsio/workspaces.rb