Class: Twilio::REST::PreviewIam::Versionless::OrganizationContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview_iam/versionless/organization.rb,
lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb,
lib/twilio-ruby/rest/preview_iam/versionless/organization/account.rb,
lib/twilio-ruby/rest/preview_iam/versionless/organization/role_assignment.rb

Defined Under Namespace

Classes: AccountContext, AccountInstance, AccountList, AccountPage, RoleAssignmentContext, RoleAssignmentInstance, RoleAssignmentList, RoleAssignmentPage, UserContext, UserInstance, UserList, UserPage

Instance Method Summary collapse

Constructor Details

#initialize(version, organization_sid) ⇒ OrganizationContext

Initialize the OrganizationContext

Parameters:

  • version (Version)

    Version that contains the resource

  • organization_sid (String)


49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization.rb', line 49

def initialize(version, organization_sid)
    super(version)

    # Path Solution
    @solution = { organization_sid: organization_sid,  }
    @uri = "/#{@solution[:organization_sid]}"

    # Dependents
    @resource_types = nil
    @role_assignments = nil
    @accounts = nil
    @users = nil
end

Instance Method Details

#accounts(account_sid = :unset) ⇒ AccountList, AccountContext

Access the accounts

Returns:

Raises:

  • (ArgumentError)


115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization.rb', line 115

def accounts(=:unset)

    raise ArgumentError, 'account_sid cannot be nil' if .nil?

    if  != :unset
        return AccountContext.new(@version, @solution[:organization_sid], )
    end

    unless @accounts
        @accounts = AccountList.new(
            @version, organization_sid: @solution[:organization_sid], )
    end

 @accounts
end

#fetchOrganizationInstance

Fetch the OrganizationInstance

Returns:



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization.rb', line 65

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    headers['Accept'] = 'application/scim+json'
    
    payload = @version.fetch('GET', @uri, headers: headers)
    OrganizationInstance.new(
        @version,
        payload,
        organization_sid: @solution[:organization_sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



159
160
161
162
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization.rb', line 159

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.PreviewIam.Versionless.OrganizationContext #{context}>"
end

#resource_typesResourceTypeList, ResourceTypeContext

Access the resource_types

Returns:

  • (ResourceTypeList)
  • (ResourceTypeContext)


85
86
87
88
89
90
91
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization.rb', line 85

def resource_types
  unless @resource_types
    @resource_types = ResourceTypeList.new(
            @version, )
  end
  @resource_types
end

#role_assignments(sid = :unset) ⇒ RoleAssignmentList, RoleAssignmentContext

Access the role_assignments

Returns:

Raises:

  • (ArgumentError)


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization.rb', line 96

def role_assignments(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return RoleAssignmentContext.new(@version, @solution[:organization_sid],sid )
    end

    unless @role_assignments
        @role_assignments = RoleAssignmentList.new(
            @version, organization_sid: @solution[:organization_sid], )
    end

 @role_assignments
end

#to_sObject

Provide a user friendly representation



152
153
154
155
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization.rb', line 152

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.PreviewIam.Versionless.OrganizationContext #{context}>"
end

#users(id = :unset) ⇒ UserList, UserContext

Access the users

Returns:

Raises:

  • (ArgumentError)


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization.rb', line 134

def users(id=:unset)

    raise ArgumentError, 'id cannot be nil' if id.nil?

    if id != :unset
        return UserContext.new(@version, @solution[:organization_sid],id )
    end

    unless @users
        @users = UserList.new(
            @version, organization_sid: @solution[:organization_sid], )
    end

 @users
end