Class: AnalyticsOps::DesiredState

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

Overview

Validated, immutable desired state for one named profile.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile:, property_id:, streams:, retention:, key_events:, custom_dimensions:, custom_metrics:, manual_requirements:, google_signals:, labels: {}, reports: {}, health: nil, funnels: {}, bigquery: nil, governance: nil) ⇒ DesiredState

Returns a new instance of DesiredState.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/analytics_ops/desired_state.rb', line 13

def initialize(profile:, property_id:, streams:, retention:, key_events:, custom_dimensions:, custom_metrics:,
               manual_requirements:, google_signals:, labels: {}, reports: {}, health: nil, funnels: {},
               bigquery: nil, governance: nil)
  @profile = Canonical.immutable(profile)
  @property_id = Canonical.immutable(property_id)
  @streams = Canonical.immutable(streams)
  @retention = Canonical.immutable(retention)
  @key_events = Canonical.immutable(key_events)
  @custom_dimensions = Canonical.immutable(custom_dimensions)
  @custom_metrics = Canonical.immutable(custom_metrics)
  @manual_requirements = Canonical.immutable(manual_requirements)
  @google_signals = Canonical.immutable(google_signals)
  @labels = Canonical.immutable(labels)
  @reports = immutable_values(reports)
  @health = Canonical.immutable(health)
  @funnels = immutable_values(funnels)
  @bigquery = Canonical.immutable(bigquery)
  @governance = Canonical.immutable(governance)
  freeze
end

Instance Attribute Details

#bigqueryrecord? (readonly)

Returns the value of attribute bigquery.

Returns:

  • (record, nil)


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def bigquery
  @bigquery
end

#custom_dimensionsArray[record] (readonly)

Returns the value of attribute custom_dimensions.

Returns:

  • (Array[record])


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def custom_dimensions
  @custom_dimensions
end

#custom_metricsArray[record] (readonly)

Returns the value of attribute custom_metrics.

Returns:

  • (Array[record])


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def custom_metrics
  @custom_metrics
end

#funnelsHash[String, Funnels::Definition] (readonly)

Returns the value of attribute funnels.

Returns:



8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def funnels
  @funnels
end

#google_signalsrecord? (readonly)

Returns the value of attribute google_signals.

Returns:

  • (record, nil)


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def google_signals
  @google_signals
end

#governancerecord? (readonly)

Returns the value of attribute governance.

Returns:

  • (record, nil)


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def governance
  @governance
end

#healthrecord? (readonly)

Returns the value of attribute health.

Returns:

  • (record, nil)


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def health
  @health
end

#key_eventsArray[String] (readonly)

Returns the value of attribute key_events.

Returns:

  • (Array[String])


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def key_events
  @key_events
end

#labelsrecord (readonly)

Returns the value of attribute labels.

Returns:

  • (record)


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def labels
  @labels
end

#manual_requirementsArray[String] (readonly)

Returns the value of attribute manual_requirements.

Returns:

  • (Array[String])


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def manual_requirements
  @manual_requirements
end

#profileString (readonly)

Returns the value of attribute profile.

Returns:

  • (String)


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def profile
  @profile
end

#property_idString (readonly)

Returns the value of attribute property_id.

Returns:

  • (String)


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def property_id
  @property_id
end

#reportsHash[String, Reports::Definition] (readonly)

Returns the value of attribute reports.

Returns:



8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def reports
  @reports
end

#retentionrecord? (readonly)

Returns the value of attribute retention.

Returns:

  • (record, nil)


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def retention
  @retention
end

#streamsArray[record] (readonly)

Returns the value of attribute streams.

Returns:

  • (Array[record])


8
9
10
# File 'lib/analytics_ops/desired_state.rb', line 8

def streams
  @streams
end

Instance Method Details

#to_hrecord

Returns:

  • (record)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/analytics_ops/desired_state.rb', line 34

def to_h
  {
    "profile" => profile,
    "property_id" => property_id,
    "streams" => streams,
    "retention" => retention,
    "key_events" => key_events,
    "custom_dimensions" => custom_dimensions,
    "custom_metrics" => custom_metrics,
    "manual_requirements" => manual_requirements,
    "google_signals" => google_signals,
    "labels" => labels,
    "reports" => reports.transform_values(&:to_h),
    "health" => health,
    "funnels" => funnels.transform_values { |value| value.respond_to?(:to_h) ? value.to_h : value },
    "bigquery" => bigquery,
    "governance" => governance
  }
end