Class: Akamai::Client::Papi
- Inherits:
-
Base
- Object
- Base
- Akamai::Client::Papi
show all
- Defined in:
- lib/akamai/client/papi.rb
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
-
#add_rule(params, options = {}) ⇒ Object
-
#create_new_activation(params, options = {}) ⇒ Object
-
#create_property_version(property_id, from_version, from_etag, options = {}) ⇒ Object
-
#get_custom_behavior(behavior_id) ⇒ Object
-
#get_latest_property_version(property_id, options = {}) ⇒ Object
-
#get_property(property_id, contract_id, group_id) ⇒ Object
-
#get_property_version(property_id, version, options = {}) ⇒ Object
-
#get_rule_tree(property_id, version, options = {}) ⇒ Object
-
#list_contracts ⇒ Object
-
#list_cp_codes(contract_id, group_id) ⇒ Object
-
#list_custom_behaviors ⇒ Object
-
#list_edge_hostnames(contract_id, group_id, options = {}) ⇒ Object
-
#list_groups ⇒ Object
-
#list_hostnames(property_id, property_version, options = {}) ⇒ Object
-
#list_products(contract_id) ⇒ Object
-
#list_properties(contract_id, group_id) ⇒ Object
-
#list_property_versions(property_id, options = {}) ⇒ Object
-
#update_rule_tree(property_id, version, rules, options = {}) ⇒ Object
Methods inherited from Base
#initialize
Instance Method Details
#add_rule(params, options = {}) ⇒ Object
126
127
128
129
130
131
132
133
134
|
# File 'lib/akamai/client/papi.rb', line 126
def add_rule(params, options = {})
params_indiff = params.with_indifferent_access
rules = get_rule_tree(params_indiff[:property_id], params_indiff[:version], options)[:rules]
unless params_indiff[:parent_node].blank?
return add_rule_to_sub_node(params_indiff, rules, options)
end
rules[:children] << params_indiff[:rule]
update_rule_tree(params_indiff[:property_id], params_indiff[:version], rules, options)
end
|
#create_new_activation(params, options = {}) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/akamai/client/papi.rb', line 104
def create_new_activation(params, options = {})
path = build_full_path(
"properties/#{params[:property_id]}/activations",
options
)
body = {
notifyEmails: params[:notify_emails] ? params[:notify_emails] : [],
network: params[:network], propertyVersion: params[:version],
note: params[:note] ? params[:note] : "", acknowledgeWarnings: []
}
retry_create_activation(path, body)
end
|
#create_property_version(property_id, from_version, from_etag, options = {}) ⇒ Object
95
96
97
98
99
100
101
102
|
# File 'lib/akamai/client/papi.rb', line 95
def create_property_version(property_id, from_version, from_etag, options = {})
path = build_full_path(
"properties/#{property_id}/versions",
options
)
body = { createFromVersion: from_version, createFromVersionEtag: from_etag }.to_json
client.post(path, body).body.to_hash["versionLink"].split("/")[-1].to_i
end
|
#get_custom_behavior(behavior_id) ⇒ Object
72
73
74
|
# File 'lib/akamai/client/papi.rb', line 72
def get_custom_behavior(behavior_id)
get("custom-behaviors", behavior_id: behavior_id)
end
|
#get_latest_property_version(property_id, options = {}) ⇒ Object
87
88
89
90
91
92
93
|
# File 'lib/akamai/client/papi.rb', line 87
def get_latest_property_version(property_id, options = {})
path = build_full_path(
"properties/#{property_id}/versions/latest",
options
)
client.get(path).body.to_hash["versionLink"].split("/")[-1].to_i
end
|
#get_property(property_id, contract_id, group_id) ⇒ Object
55
56
57
58
59
|
# File 'lib/akamai/client/papi.rb', line 55
def get_property(property_id, contract_id, group_id)
get(
"properties/#{property_id}", contract_id: contract_id, group_id: group_id
)
end
|
#get_property_version(property_id, version, options = {}) ⇒ Object
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/akamai/client/papi.rb', line 76
def get_property_version(property_id, version, options = {})
path = build_full_path(
"properties/#{property_id}/versions/#{version}",
options
)
response = client.get(path)
transform_to_snakecase(
response.body[:versions][:items]
)[0]
end
|
#get_rule_tree(property_id, version, options = {}) ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/akamai/client/papi.rb', line 61
def get_rule_tree(property_id, version, options = {})
path = build_full_path(
"properties/#{property_id}/versions/#{version}/rules",
options
)
response = client.get(path)
transform_to_snakecase(
response.body
)
end
|
#list_contracts ⇒ Object
10
11
12
|
# File 'lib/akamai/client/papi.rb', line 10
def list_contracts
get(:contracts)
end
|
#list_cp_codes(contract_id, group_id) ⇒ Object
22
23
24
|
# File 'lib/akamai/client/papi.rb', line 22
def list_cp_codes(contract_id, group_id)
get(:cpcodes, contract_id: contract_id, group_id: group_id)
end
|
#list_custom_behaviors ⇒ Object
14
15
16
|
# File 'lib/akamai/client/papi.rb', line 14
def list_custom_behaviors
get("custom-behaviors")
end
|
#list_edge_hostnames(contract_id, group_id, options = {}) ⇒ Object
51
52
53
|
# File 'lib/akamai/client/papi.rb', line 51
def list_edge_hostnames(contract_id, group_id, options = {})
get(:edgeHostnames, {contract_id: contract_id, group_id: group_id}.merge(options))
end
|
#list_groups ⇒ Object
6
7
8
|
# File 'lib/akamai/client/papi.rb', line 6
def list_groups
get(:groups)
end
|
#list_hostnames(property_id, property_version, options = {}) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/akamai/client/papi.rb', line 40
def list_hostnames(property_id, property_version, options = {})
path = build_full_path(
"properties/#{property_id}/versions/#{property_version}/hostnames",
options
)
response = client.get(path)
transform_to_snakecase(
response.body[:hostnames][:items]
)
end
|
#list_products(contract_id) ⇒ Object
18
19
20
|
# File 'lib/akamai/client/papi.rb', line 18
def list_products(contract_id)
get(:products, contract_id: contract_id)
end
|
#list_properties(contract_id, group_id) ⇒ Object
26
27
28
|
# File 'lib/akamai/client/papi.rb', line 26
def list_properties(contract_id, group_id)
get(:properties, contract_id: contract_id, group_id: group_id)
end
|
#list_property_versions(property_id, options = {}) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/akamai/client/papi.rb', line 30
def list_property_versions(property_id, options = {})
path = build_full_path(
"properties/#{property_id}/versions", options
)
response = client.get(path)
transform_to_snakecase(
response.body[:versions][:items]
)
end
|
#update_rule_tree(property_id, version, rules, options = {}) ⇒ Object
117
118
119
120
121
122
123
124
|
# File 'lib/akamai/client/papi.rb', line 117
def update_rule_tree(property_id, version, rules, options = {})
path = build_full_path(
"properties/#{property_id}/versions/#{version}/rules",
options
)
body = { rules: rules }.to_json
client.put(path, body)
end
|