Sha256: 84d8c6b0e7530ce8cf206f19bf0f68b6d72594c58d47bff90e7c0c5545e89982

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 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
      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

7 entries across 7 versions & 1 rubygems

Version Path
gooddata-1.0.2-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-1.0.2 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-1.0.1 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-1.0.1-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-1.0.0-java lib/gooddata/lcm/actions/purge_clients.rb
gooddata-1.0.0 lib/gooddata/lcm/actions/purge_clients.rb
gooddata-0.6.54 lib/gooddata/lcm/actions/purge_clients.rb