Class Resource
Represents a resource in the Okta API.
Inheritance
Implements
Inherited Members
Namespace: Okta.Sdk
Assembly: Okta.Sdk.dll
Syntax
public class Resource : IResource
Constructors
Resource()
Initializes a new instance of the Resource class.
Declaration
public Resource()
Properties
Item[String]
Gets or sets a resource property by name.
Declaration
public object this[string name] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Property Value
Type | Description |
---|---|
System.Object | The property value, or |
Methods
GetArrayProperty<T>(String)
Gets a list or array property from the resource by name.
Declaration
public IList<T> GetArrayProperty<T>(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<T> | A System.Collections.Generic.IList<T> that can be enumerated to obtain the property items. |
Type Parameters
Name | Description |
---|---|
T | The type of items contained in the list or array. |
GetBooleanProperty(String)
Gets a System.Boolean property from the resource by name.
Declaration
protected bool? GetBooleanProperty(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
System.Nullable<System.Boolean> | The property value as a System.Boolean, or |
Exceptions
Type | Condition |
---|---|
System.FormatException | The value is not equal to the value of the System.Boolean.TrueString or System.Boolean.FalseString field. |
GetClient()
Gets the IOktaClient that created this resource.
Declaration
protected IOktaClient GetClient()
Returns
Type | Description |
---|---|
IOktaClient | The IOktaClient that created this resource. |
GetData()
Gets the underlying data backing this resource.
Declaration
public IDictionary<string, object> GetData()
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> | The data backing this resource. |
GetDateTimeProperty(String)
Gets a datetime property from the resource by name.
Declaration
protected DateTimeOffset? GetDateTimeProperty(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
System.Nullable<System.DateTimeOffset> | The property value as a System.DateTimeOffset, or |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The offset is greater than 14 hours or less than -14 hours. |
System.FormatException | The value does not contain a valid string representation of a date and time, or the value contains the string representation of an offset value without a date or time. |
GetDoubleProperty(String)
Gets a System.Double property from the resource by name.
Declaration
protected double? GetDoubleProperty(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
System.Nullable<System.Double> | The property value as a System.Double, or |
Exceptions
Type | Condition |
---|---|
System.FormatException | The value is not in the correct format. |
System.OverflowException | The value represents a number less than System.Double.MinValue or greater than System.Double.MaxValue. |
GetEnumProperty<TEnum>(String)
Gets a string enum property from the resource by name.
Declaration
protected TEnum GetEnumProperty<TEnum>(string name)
where TEnum : StringEnum
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
TEnum | The property value wrapped in the specified enum type, or |
Type Parameters
Name | Description |
---|---|
TEnum | The enum type. |
Exceptions
Type | Condition |
---|---|
OktaException | The enum type could not be created. |
GetIntegerProperty(String)
Gets an System.Int32 property from the resource by name.
Declaration
protected int? GetIntegerProperty(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
System.Nullable<System.Int32> | The property value as an System.Int32, or |
Exceptions
Type | Condition |
---|---|
System.FormatException | The value is not in the correct format. |
System.OverflowException | The value represents a number less than System.Int32.MinValue or greater than System.Int32.MaxValue. |
GetLongProperty(String)
Gets a System.Int64 property from the resource by name.
Declaration
protected long? GetLongProperty(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
System.Nullable<System.Int64> | The property value as a System.Int64, or |
Exceptions
Type | Condition |
---|---|
System.FormatException | The value is not in the correct format. |
System.OverflowException | The value represents a number less than System.Int64.MinValue or greater than System.Int64.MaxValue. |
GetProperty<T>(String)
Gets a resource property by name.
Declaration
public T GetProperty<T>(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
T | The strongly-typed property value, or |
Type Parameters
Name | Description |
---|---|
T | The property type. |
Remarks
In derived classes, use the more specific methods such as GetStringProperty(String) and GetIntegerProperty(String) instead.
GetResourceProperty<T>(String)
Gets an embedded resource property by name.
Declaration
protected T GetResourceProperty<T>(string name)
where T : Resource, new()
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
T | The embedded resource, or |
Type Parameters
Name | Description |
---|---|
T | The type of the embedded resource. |
GetStringProperty(String)
Gets a System.String property from the resource by name.
Declaration
protected string GetStringProperty(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name. |
Returns
Type | Description |
---|---|
System.String | The property value as a System.String, or |
SetProperty(String, Object)
Sets a resource property by name
Declaration
public void SetProperty(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property name |
System.Object | value | The property value |