Sha256: 0736d484e8f5fa50cdf31a6f25df765aae22257ba085da4d5e1ce5aaa374f35f

Contents?: true

Size: 1.47 KB

Versions: 7

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

# Copyright 2018 Tristan Robert

# This file is part of Fog::Proxmox.

# Fog::Proxmox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Fog::Proxmox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.

require 'fog/proxmox/models/collection'
require 'fog/identity/proxmox/models/user'

module Fog
  module Identity
    class Proxmox
      # class Users model collection
      class Users < Fog::Proxmox::Collection
        model Fog::Identity::Proxmox::User

        def all(options = {})
          load_response(service.list_users(options), 'users')
        end

        def find_by_id(id)
          cached_user = find { |user| user.userid == id }
          return cached_user if cached_user
          user_hash = service.get_user(id)
          Fog::Identity::Proxmox::User.new(
            user_hash.merge(service: service)
          )
        end

        def destroy(id)
          user = find_by_id(id)
          user.destroy
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fog-proxmox-0.5.5 lib/fog/identity/proxmox/models/users.rb
fog-proxmox-0.5.4 lib/fog/identity/proxmox/models/users.rb
fog-proxmox-0.5.3 lib/fog/identity/proxmox/models/users.rb
fog-proxmox-0.5.2 lib/fog/identity/proxmox/models/users.rb
fog-proxmox-0.5.1 lib/fog/identity/proxmox/models/users.rb
fog-proxmox-0.5.0 lib/fog/identity/proxmox/models/users.rb
fog-proxmox-0.4.0 lib/fog/identity/proxmox/models/users.rb