Class: Twilio::REST::Iam::V1::ApiKeyContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/iam/v1/api_key.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ApiKeyContext

Initialize the ApiKeyContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The Twilio-provided string that uniquely identifies the Key resource to update.



49
50
51
52
53
54
55
56
57
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 49

def initialize(version, sid)
    super(version)

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

    
end

Instance Method Details

#deleteBoolean

Delete the ApiKeyInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



61
62
63
64
65
66
67
68
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 61

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchApiKeyInstance

Fetch the ApiKeyInstance

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 73

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



128
129
130
131
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 128

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

#to_sObject

Provide a user friendly representation



121
122
123
124
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 121

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

#update(friendly_name: :unset, policy: :unset) ⇒ ApiKeyInstance

Update the ApiKeyInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

  • policy (Object) (defaults to: :unset)

    The \\‘Policy\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys).

Returns:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 94

def update(
    friendly_name: :unset, 
    policy: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Policy' => Twilio.serialize_object(policy),
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    ApiKeyInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end