browse_ai 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/browse_ai/dsl/bulk_runs.rb +41 -0
- data/lib/browse_ai/dsl.rb +2 -0
- data/lib/browse_ai/resources/bulk_run.rb +8 -0
- data/lib/browse_ai/resources.rb +1 -0
- data/lib/browse_ai/version.rb +1 -1
- data/spec/browse_ai/dsl/bulk_runs_spec.rb +53 -0
- metadata +5 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4e7866506b5497da51c581127b313886e293c42b7751e582d043d378bfebfcf3
         | 
| 4 | 
            +
              data.tar.gz: c776eeae73a97f1581de1ae3e11f1f34c174666b961b07e3f73efd6ec1eb15c6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0534b89bb1a07bda3d140e6e9b6442743e1c1b1148c652bdf28f77a212c57f84cc667e7a3bea3d1fcc6b1ce13a297784192afe56c154b30cd5cd3ce1e5d053c5
         | 
| 7 | 
            +
              data.tar.gz: 4f7e32004d613edb8fe7185714b4bdf2038f3a4b4deb9c01dab3c75d9f82b4af1d0dc6cf066a125d4451c26b8fd47167975dcb77e2d61e16b43d672e302942df
         | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            require 'browse_ai/dsl'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module BrowseAi
         | 
| 4 | 
            +
              module DSL::BulkRuns
         | 
| 5 | 
            +
                # POST /robots/{robotId}/bulk-runs
         | 
| 6 | 
            +
                # Executes a bulk run on a robot.
         | 
| 7 | 
            +
                # @param [String] robot_id The ID of the robot the bulk_runs belongs to.
         | 
| 8 | 
            +
                # @param [String] :payload The JSON payload to send to the robot.
         | 
| 9 | 
            +
                # @raise [ArgumentError] If the method arguments are blank.
         | 
| 10 | 
            +
                # @return [BrowseAi::Resources::BulkRun, nil].
         | 
| 11 | 
            +
                def bulk_run_tasks(robot_id:, payload:)
         | 
| 12 | 
            +
                  raise ArgumentError, 'Robot ID cannot be blank' if robot_id.blank?
         | 
| 13 | 
            +
                  raise ArgumentError, 'Payload cannot be blank' if payload.blank?
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  Resources::BulkRun.parse(request(:post, "robots/#{robot_id}/bulk_runs/", payload), %w[result bulkRun])
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                # GET robots/{robotId}/bulk-runs
         | 
| 19 | 
            +
                # Get bulk_runs.
         | 
| 20 | 
            +
                # @param [String] robot_id The ID of the robot the bulk runs belongs to.
         | 
| 21 | 
            +
                # @raise [ArgumentError] If the method arguments are blank.
         | 
| 22 | 
            +
                # @return [Array, nil].
         | 
| 23 | 
            +
                def get_bulk_runs(robot_id:)
         | 
| 24 | 
            +
                  raise ArgumentError, 'Robot ID cannot be blank' if robot_id.blank?
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  Resources::BulkRun.parse(request(:get, "robots/#{robot_id}/bulk-runs/", nil), %w[result items])
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                # GET robots/{robotId}/bulk-runs/{id}
         | 
| 30 | 
            +
                # Get a bulk_run.
         | 
| 31 | 
            +
                # @param [String] id A bulk run's ID.
         | 
| 32 | 
            +
                # @raise [ArgumentError] If the method arguments are blank.
         | 
| 33 | 
            +
                # @return [BrowseAi::Resources::BulkRun, nil].
         | 
| 34 | 
            +
                def get_bulk_run(robot_id:, id:)
         | 
| 35 | 
            +
                  raise ArgumentError, 'Robot ID cannot be blank' if robot_id.blank?
         | 
| 36 | 
            +
                  raise ArgumentError, 'ID cannot be blank' if id.blank?
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  Resources::BulkRun.parse(request(:get, "robots/#{robot_id}/bulk-runs/#{id}"), %w[result bulkRun])
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
    
        data/lib/browse_ai/dsl.rb
    CHANGED
    
    | @@ -5,6 +5,7 @@ module BrowseAi | |
| 5 5 | 
             
              end
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            +
            require 'browse_ai/dsl/bulk_runs'
         | 
| 8 9 | 
             
            require 'browse_ai/dsl/monitors'
         | 
| 9 10 | 
             
            require 'browse_ai/dsl/robots'
         | 
| 10 11 | 
             
            require 'browse_ai/dsl/tasks'
         | 
| @@ -14,6 +15,7 @@ require 'mime-types' | |
| 14 15 |  | 
| 15 16 | 
             
            module BrowseAi
         | 
| 16 17 | 
             
              module DSL
         | 
| 18 | 
            +
                include BulkRuns
         | 
| 17 19 | 
             
                include Monitors
         | 
| 18 20 | 
             
                include Robots
         | 
| 19 21 | 
             
                include Tasks
         | 
    
        data/lib/browse_ai/resources.rb
    CHANGED
    
    
    
        data/lib/browse_ai/version.rb
    CHANGED
    
    
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe BrowseAi::DSL::BulkRuns do
         | 
| 4 | 
            +
              def robot_id
         | 
| 5 | 
            +
                VCR.use_cassette('get_robots') do
         | 
| 6 | 
            +
                  robots = BrowseAi.client.get_robots
         | 
| 7 | 
            +
                  robots.first['id']
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              # POST /robots/{robotId}/bulk-runs
         | 
| 12 | 
            +
              describe '#bulk_run_tasks' do
         | 
| 13 | 
            +
                let(:payload) do
         | 
| 14 | 
            +
                  {
         | 
| 15 | 
            +
                    'inputParameters' => {
         | 
| 16 | 
            +
                      'originUrl' => 'Test',
         | 
| 17 | 
            +
                    }
         | 
| 18 | 
            +
                  }.to_json
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                it 'creates a bulk run and executes it on the robot' do
         | 
| 22 | 
            +
                  VCR.use_cassette('bulk_run_tasks') do
         | 
| 23 | 
            +
                    bulk_run = BrowseAi.client.bulk_run_tasks(robot_id:, payload:)
         | 
| 24 | 
            +
                    expect(bulk_run).to be_a(BulkRun)
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              # GET robots/{robotId}/bulk_runs
         | 
| 30 | 
            +
              describe '#get_bulk_runs' do
         | 
| 31 | 
            +
                it 'returns an array of bulk_runs' do
         | 
| 32 | 
            +
                  VCR.use_cassette('get_bulk_runs') do
         | 
| 33 | 
            +
                    bulk_runs = BrowseAi.client.get_bulk_runs(robot_id:)
         | 
| 34 | 
            +
                    expect(bulk_runs).to be_a(Array)
         | 
| 35 | 
            +
                    expect(bulk_runs.first).to be_a(BulkRun)
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              # GET robots/{robotId}/bulk_runs/{id}
         | 
| 41 | 
            +
              describe '#get_bulk_run' do
         | 
| 42 | 
            +
                it 'returns an bulk_run' do
         | 
| 43 | 
            +
                  id = VCR.use_cassette('get_bulk_runs') do
         | 
| 44 | 
            +
                    bulk_runs = BrowseAi.client.get_bulk_runs(robot_id:)
         | 
| 45 | 
            +
                    bulk_runs.first['id']
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  VCR.use_cassette('get_bulk_run') do
         | 
| 49 | 
            +
                    expect(BrowseAi.client.get_bulk_run(robot_id:, id:)).to be_a(BulkRun)
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: browse_ai
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - David Iorns
         | 
| @@ -184,6 +184,7 @@ files: | |
| 184 184 | 
             
            - lib/browse_ai.rb
         | 
| 185 185 | 
             
            - lib/browse_ai/client.rb
         | 
| 186 186 | 
             
            - lib/browse_ai/dsl.rb
         | 
| 187 | 
            +
            - lib/browse_ai/dsl/bulk_runs.rb
         | 
| 187 188 | 
             
            - lib/browse_ai/dsl/monitors.rb
         | 
| 188 189 | 
             
            - lib/browse_ai/dsl/robots.rb
         | 
| 189 190 | 
             
            - lib/browse_ai/dsl/tasks.rb
         | 
| @@ -192,6 +193,7 @@ files: | |
| 192 193 | 
             
            - lib/browse_ai/errors/client_error.rb
         | 
| 193 194 | 
             
            - lib/browse_ai/errors/resource_not_found_error.rb
         | 
| 194 195 | 
             
            - lib/browse_ai/resources.rb
         | 
| 196 | 
            +
            - lib/browse_ai/resources/bulk_run.rb
         | 
| 195 197 | 
             
            - lib/browse_ai/resources/monitor.rb
         | 
| 196 198 | 
             
            - lib/browse_ai/resources/object.rb
         | 
| 197 199 | 
             
            - lib/browse_ai/resources/object/attributes.rb
         | 
| @@ -203,6 +205,7 @@ files: | |
| 203 205 | 
             
            - lib/browse_ai/utils/url_helper.rb
         | 
| 204 206 | 
             
            - lib/browse_ai/version.rb
         | 
| 205 207 | 
             
            - spec/browse_ai/client_spec.rb
         | 
| 208 | 
            +
            - spec/browse_ai/dsl/bulk_runs_spec.rb
         | 
| 206 209 | 
             
            - spec/browse_ai/dsl/monitors_spec.rb
         | 
| 207 210 | 
             
            - spec/browse_ai/dsl/robots_spec.rb
         | 
| 208 211 | 
             
            - spec/browse_ai/dsl/tasks_spec.rb
         | 
| @@ -231,6 +234,7 @@ specification_version: 4 | |
| 231 234 | 
             
            summary: A Ruby wrapper for the Browse AI API. https://www.browse.ai/docs/api/v2
         | 
| 232 235 | 
             
            test_files:
         | 
| 233 236 | 
             
            - spec/browse_ai/client_spec.rb
         | 
| 237 | 
            +
            - spec/browse_ai/dsl/bulk_runs_spec.rb
         | 
| 234 238 | 
             
            - spec/browse_ai/dsl/monitors_spec.rb
         | 
| 235 239 | 
             
            - spec/browse_ai/dsl/robots_spec.rb
         | 
| 236 240 | 
             
            - spec/browse_ai/dsl/tasks_spec.rb
         |