This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
forked from inspec/inspec-gcp
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgoogle_compute_https_health_check.rb
80 lines (69 loc) · 2.21 KB
/
google_compute_https_health_check.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# frozen_string_literal: false
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
# A provider to manage Compute Engine resources.
class HttpsHealthCheck < GcpResourceBase
name 'google_compute_https_health_check'
desc 'HttpsHealthCheck'
supports platform: 'gcp'
attr_reader :params
attr_reader :check_interval_sec
attr_reader :creation_timestamp
attr_reader :description
attr_reader :healthy_threshold
attr_reader :host
attr_reader :id
attr_reader :name
attr_reader :port
attr_reader :request_path
attr_reader :timeout_sec
attr_reader :unhealthy_threshold
def initialize(params)
super(params.merge({ use_http_transport: true }))
@params = params
@fetched = @connection.fetch(product_url, resource_base_url, params)
parse unless @fetched.nil?
end
def parse
@check_interval_sec = @fetched['checkIntervalSec']
@creation_timestamp = parse_time_string(@fetched['creationTimestamp'])
@description = @fetched['description']
@healthy_threshold = @fetched['healthyThreshold']
@host = @fetched['host']
@id = @fetched['id']
@name = @fetched['name']
@port = @fetched['port']
@request_path = @fetched['requestPath']
@timeout_sec = @fetched['timeoutSec']
@unhealthy_threshold = @fetched['unhealthyThreshold']
end
# Handles parsing RFC3339 time string
def parse_time_string(time_string)
time_string ? Time.parse(time_string) : nil
end
def exists?
!@fetched.nil?
end
def to_s
"HttpsHealthCheck #{@params[:name]}"
end
private
def product_url
'https://www.googleapis.com/compute/v1/'
end
def resource_base_url
'projects/{{project}}/global/httpsHealthChecks/{{name}}'
end
end