Class: Vault::Transform

Inherits:
Request show all
Defined in:
lib/vault/api/transform.rb,
lib/vault/api/transform/role.rb,
lib/vault/api/transform/alphabet.rb,
lib/vault/api/transform/template.rb,
lib/vault/api/transform/transformation.rb

Defined Under Namespace

Classes: Alphabet, Role, Template, Transformation

Instance Attribute Summary

Attributes inherited from Request

#client

Instance Method Summary collapse

Methods inherited from Request

#initialize, #inspect, #to_s

Methods included from EncodePath

encode_path

Constructor Details

This class inherits a constructor from Vault::Request

Instance Method Details

#alphabetsObject



37
38
39
40
41
42
43
44
# File 'lib/vault/api/transform/alphabet.rb', line 37

def alphabets
  json = client.list("/v1/transform/alphabet")
  if keys = json.dig(:data, :keys)
    keys
  else
    json
  end
end

#create_alphabet(name, alphabet:, **opts) ⇒ Object



16
17
18
19
20
21
# File 'lib/vault/api/transform/alphabet.rb', line 16

def create_alphabet(name, alphabet:, **opts)
  opts ||= {}
  opts[:alphabet] = alphabet
  client.post("/v1/transform/alphabet/#{encode_path(name)}", JSON.fast_generate(opts))
  return true
end

#create_role(name, **opts) ⇒ Object



16
17
18
19
20
# File 'lib/vault/api/transform/role.rb', line 16

def create_role(name, **opts)
  opts ||= {}
  client.post("/v1/transform/role/#{encode_path(name)}", JSON.fast_generate(opts))
  return true
end

#create_template(name, type:, pattern:, **opts) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/vault/api/transform/template.rb', line 26

def create_template(name, type:, pattern:, **opts)
  opts ||= {}
  opts[:type] = type
  opts[:pattern] = pattern
  client.post("/v1/transform/template/#{encode_path(name)}", JSON.fast_generate(opts))
  return true
end

#create_transformation(name, type:, template:, **opts) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/vault/api/transform/transformation.rb', line 33

def create_transformation(name, type:, template:, **opts)
  opts ||= {}
  opts[:type] = type
  opts[:template] = template
  client.post("/v1/transform/transformation/#{encode_path(name)}", JSON.fast_generate(opts))
  return true
end

#decode(role_name:, **opts) ⇒ Object



22
23
24
25
# File 'lib/vault/api/transform.rb', line 22

def decode(role_name:, **opts)
  opts ||= {}
  client.post("/v1/transform/decode/#{encode_path(role_name)}", JSON.fast_generate(opts))
end

#delete_alphabet(name) ⇒ Object



32
33
34
35
# File 'lib/vault/api/transform/alphabet.rb', line 32

def delete_alphabet(name)
  client.delete("/v1/transform/alphabet/#{encode_path(name)}")
  true
end

#delete_role(name) ⇒ Object



31
32
33
34
# File 'lib/vault/api/transform/role.rb', line 31

def delete_role(name)
  client.delete("/v1/transform/role/#{encode_path(name)}")
  true
end

#delete_template(name) ⇒ Object



43
44
45
46
# File 'lib/vault/api/transform/template.rb', line 43

def delete_template(name)
  client.delete("/v1/transform/template/#{encode_path(name)}")
  true
end

#delete_transformation(name) ⇒ Object



50
51
52
53
# File 'lib/vault/api/transform/transformation.rb', line 50

def delete_transformation(name)
  client.delete("/v1/transform/transformation/#{encode_path(name)}")
  true
end

#encode(role_name:, **opts) ⇒ Object



17
18
19
20
# File 'lib/vault/api/transform.rb', line 17

def encode(role_name:, **opts)
  opts ||= {}
  client.post("/v1/transform/encode/#{encode_path(role_name)}", JSON.fast_generate(opts))
end

#get_alphabet(name) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/vault/api/transform/alphabet.rb', line 23

def get_alphabet(name)
  json = client.get("/v1/transform/alphabet/#{encode_path(name)}")
  if data = json.dig(:data)
    Alphabet.decode(data)
  else
    json
  end
end

#get_role(name) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/vault/api/transform/role.rb', line 22

def get_role(name)
  json = client.get("/v1/transform/role/#{encode_path(name)}")
  if data = json.dig(:data)
    Role.decode(data)
  else
    json
  end
end

#get_template(name) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/vault/api/transform/template.rb', line 34

def get_template(name)
  json = client.get("/v1/transform/template/#{encode_path(name)}")
  if data = json.dig(:data)
    Template.decode(data)
  else
    json
  end
end

#get_transformation(name) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/vault/api/transform/transformation.rb', line 41

def get_transformation(name)
  json = client.get("/v1/transform/transformation/#{encode_path(name)}")
  if data = json.dig(:data)
    Transformation.decode(data)
  else
    json
  end
end

#rolesObject



36
37
38
39
40
41
42
43
# File 'lib/vault/api/transform/role.rb', line 36

def roles
  json = client.list("/v1/transform/role")
  if keys = json.dig(:data, :keys)
    keys
  else
    json
  end
end

#templatesObject



48
49
50
51
52
53
54
55
# File 'lib/vault/api/transform/template.rb', line 48

def templates
  json = client.list("/v1/transform/template")
  if keys = json.dig(:data, :keys)
    keys
  else
    json
  end
end

#transformationsObject



55
56
57
58
59
60
61
62
# File 'lib/vault/api/transform/transformation.rb', line 55

def transformations
  json = client.list("/v1/transform/transformation")
  if keys = json.dig(:data, :keys)
    keys
  else
    json
  end
end