Sha256: 2f9e57d4e0ad7edbe10f5dc181aa06d3e810b9fe74a8fc45c076caccb821dd2d

Contents?: true

Size: 1.47 KB

Versions: 66

Compression:

Stored size: 1.47 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require_relative 'base_action'

module GoodData
  module LCM2
    class PurgeClients < BaseAction
      DESCRIPTION = 'Purge LCM Clients'

      PARAMS = define_params(self) do
        description 'Client projects'
        param :client_projects, instance_of(Type::GdSmartHashType), required: false
      end

      RESULT_HEADER = [
        :client_id,
        :project,
        :status
      ]

      class << self
        def call(params)
          client_projects = params.client_projects

          results = client_projects.pmap do |_, info|
            client = info[:segment_client]
            project = info[:project]

            res = {
              client_id: client.client_id,
              project: project && project.pid
            }

            if project.nil? || project.deleted?
              client.delete
              res[:status] = 'purged'
            else
              res[:status] = 'ok - not purged'
            end

            res
          end

          results.pselect { |res| res[:status] == 'purged' }.pmap { |res| res[:client_id] }.each { |id| client_projects.delete(id) }

          {
            results: results,
            params: {
              client_projects: client_projects
            }
          }
        end
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
gooddata-2.3.1-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.3.1 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.3.0-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.3.0 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.2.0-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.2.0 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.19-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.19 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.17-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.17 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.15-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.15 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.14-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.14 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.13-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.13 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.12-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.12 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.11-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-2.1.11 lib/gooddata/lcm/actions/purge_clients.rb