Class: Chef::Resource::ChefOrganization

Inherits:
LWRPBase
  • Object
show all
Defined in:
lib/chef/resource/chef_organization.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ChefOrganization

Grab environment from with_environment



12
13
14
15
16
17
18
# File 'lib/chef/resource/chef_organization.rb', line 12

def initialize(*args)
  super
  chef_server run_context.cheffish.current_chef_server
  @invites = nil
  @members = nil
  @remove_members = []
end

Instance Method Details

#invites(*users) ⇒ Object

A list of users who must at least be invited to the org (but may already be members). Invites will be sent to users who are not already invited/in the org.



25
26
27
28
29
30
31
32
# File 'lib/chef/resource/chef_organization.rb', line 25

def invites(*users)
  if users.size == 0
    @invites || []
  else
    @invites ||= []
    @invites |= users.flatten
  end
end

#invites_specified?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/chef/resource/chef_organization.rb', line 34

def invites_specified?
  !!@invites
end

#members(*users) ⇒ Object

A list of users who must be members of the org. This will use the new Chef 12 POST /organizations/ORG/users/NAME endpoint to add them directly to the org. If you do not have permission to perform this operation, and the users are not a part of the org, the resource update will fail.



42
43
44
45
46
47
48
49
# File 'lib/chef/resource/chef_organization.rb', line 42

def members(*users)
  if users.size == 0
    @members || []
  else
    @members ||= []
    @members |= users.flatten
  end
end

#members_specified?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/chef/resource/chef_organization.rb', line 51

def members_specified?
  !!@members
end

#remove_members(*users) ⇒ Object

A list of users who must not be members of the org. These users will be removed from the org and invites will be revoked (if any).



57
58
59
# File 'lib/chef/resource/chef_organization.rb', line 57

def remove_members(*users)
  users.size == 0 ? @remove_members : (@remove_members |= users.flatten)
end