Class: AnalyticsOps::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/analytics_ops/setup.rb,
sig/analytics_ops.rbs

Overview

Interactive or automated property selection after service-account loading.

Defined Under Namespace

Classes: Result

Constant Summary collapse

PROPERTY_ID =
/\A\d{1,50}\z/
PROFILE =
/\A[A-Za-z][A-Za-z0-9_]{0,63}\z/
DISABLED_API_REASONS =
%w[SERVICE_DISABLED ACCESS_NOT_CONFIGURED].freeze

Instance Method Summary collapse

Constructor Details

#initialize(connection:, config:, profile:, property_id: nil, noninteractive: false, warnings: [], input: $stdin, out: $stdout) ⇒ Setup

Returns a new instance of Setup.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/analytics_ops/setup.rb', line 65

def initialize(connection:, config:, profile:, property_id: nil, noninteractive: false,
               warnings: [], input: $stdin, out: $stdout)
  validate_options!(
    config:,
    profile:,
    property_id:,
    noninteractive:
  )
  @connection = connection
  @config = config
  @profile = profile.to_s
  @property_id = property_id
  @noninteractive = noninteractive
  @warnings = warnings
  @input = input
  @out = out
end

Instance Method Details

#callResult

Returns:



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/analytics_ops/setup.rb', line 83

def call
  selection = select_property(google_call { @connection.properties })
  verification = google_call { @connection.verify(selection.fetch("id")) }
  write = Configuration::Writer.new.write_minimal(
    @config,
    profile: @profile,
    property_id: verification.property.id
  )
  Result.new(
    config_path: write.path,
    profile: @profile,
    property: verification.property,
    created: write.created?,
    updated: write.updated?,
    warnings: @warnings
  )
end