File: secret.rb

package info (click to toggle)
ruby-fog-openstack 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,784 kB
  • sloc: ruby: 47,937; makefile: 5; sh: 4
file content (53 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download | duplicates (3)
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
require 'fog/openstack/models/model'
require 'uri'

module Fog
  module OpenStack
    class KeyManager

      class Secret < Fog::OpenStack::Model
        identity :secret_ref

        # create
        attribute :uuid
        attribute :name
        attribute :expiration
        attribute :bit_length, type: Integer
        attribute :algorithm
        attribute :mode
        attribute :secret_type

        attribute :content_types
        attribute :created
        attribute :creator_id
        attribute :status
        attribute :updated

        attribute :payload
        attribute :payload_content_type
        attribute :payload_content_encoding

        attribute :metadata

        def uuid
          URI(self.secret_ref).path.split('/').last
        rescue
          nil
        end

        def create
          merge_attributes(service.create_secret(attributes).body)
          self
        end

        def destroy
          requires :secret_ref
          service.delete_secret(uuid)
          true
        end

      end

    end
  end
end