Package com.postman.collection
Class RequestAuth
java.lang.Object
com.postman.collection.CollectionElement
com.postman.collection.RequestAuth
Postman SDK analog: 
RequestAuth.
 
 Class encapsulating the "auth" property of a Collection or RequestBody.  Collections and requests can each have a single auth property,
 which consists of a type (e.g., 'oauth1') and an array of parameters for that authentication type.  For example, oauth2 looks like:
 
 auth": {
        "type": "oauth2",
        "oauth2": [
            {
                "key": "grant_type",
                "value": "authorization_code",
                "type": "string"
            },
            {
                "key": "tokenName",
                "value": "Oauth2TokenName",
                "type": "string"
            },
            {
                "key": "tokenType",
                "value": "",
                "type": "string"
            },
            {
                "key": "accessToken",
                "value": "oauth2Token",
                "type": "string"
            },
            {
                "key": "addTokenTo",
                "value": "header",
                "type": "string"
            }
        ]
    }
    
 Properties are stored as instances of Property- 
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.RequestAuth(enumAuthType type) Conveninence constructor to initialize an Auth object with the specified type as an enumerated value.RequestAuth(enumAuthType type, PropertyList<Property> properties) Conveninence constructor to initialize an Auth object with a pre-created HashMap of authentication propertiesRequestAuth(String type) Conveninence constructor to initialize an Auth object with the specified type as String. - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddProperty(Property newElement) Add a new property, or replace an existing propertyvoidaddProperty(String key, String value) Convenience method create and then add a new property to this auth objectGet the value of the type property of this authentication object.Convenience method to return the type property of this auth object as a StringgetKey()Returns the key of this CollectionElement for use in retrieving from arrays, etc.Return the complete array of properties as a HashMap<String,Property>, or null if none are set.getProperty(String key) Retrieve a single element from the array of authentication elements comprising this authentication object.voidsetAuthType(enumAuthType type) Set the underlying type property of this auth object using an enumerated value.voidsetProperties(PropertyList<Property> properties) Set the properties of the Auth object using a pre-created HashMap<String,Property> of properties.Methods inherited from class com.postman.collection.CollectionElement
getCollection, getDefaultCollectionSchema, getDefaultValidationSchema, getParent, getUUID, getValidationMessages, isEquivalentTo, setParent, setUUID, toJson, toJson, validate, validate 
- 
Constructor Details
- 
RequestAuth
public RequestAuth()Default constructor. Resulting auth has no type or any other properties initialized. - 
RequestAuth
Conveninence constructor to initialize an Auth object with the specified type as String.- Parameters:
 type- The underlying type property of the new Auth object, as a String, e.g., "oauth1"
 - 
RequestAuth
Conveninence constructor to initialize an Auth object with the specified type as an enumerated value.- Parameters:
 type- The underlying type property of the new Auth object, as an enumeration
 - 
RequestAuth
Conveninence constructor to initialize an Auth object with a pre-created HashMap of authentication properties- Parameters:
 type- The underlying type property of the new Auth object, as a String, e.g., "oauth1"properties- HashMap<String, Property> containing the properties of this auth element
 
 - 
 - 
Method Details
- 
getKey
Returns the key of this CollectionElement for use in retrieving from arrays, etc.- Specified by:
 getKeyin classCollectionElement- Returns:
 - String
 
 - 
getAuthType
Get the value of the type property of this authentication object. The underlying string value is mapped to an enumerated value.- Returns:
 - enumAuthType The underlying type of this authentication object, e.g., `oauth1`
 
 - 
setAuthType
Set the underlying type property of this auth object using an enumerated value. If the type was previously set to a different value, the properties collection is set to null.- Parameters:
 type- Enumerated value of the underlying type property
 - 
getAuthTypeAsString
Convenience method to return the type property of this auth object as a String- Returns:
 - String The 'type' property of this auth object, e.g., 'oauth1'
 
 - 
setProperties
Set the properties of the Auth object using a pre-created HashMap<String,Property> of properties.- Parameters:
 properties-
 - 
getProperties
Return the complete array of properties as a HashMap<String,Property>, or null if none are set.- Returns:
 - HashMap<String, Property>
 
 - 
getProperty
Retrieve a single element from the array of authentication elements comprising this authentication object.- Parameters:
 key- A string matching the key of the Auth element to return. Returns null if the specified element is not present.- Returns:
 - Property The auth element, or null if not found.
 
 - 
addProperty
Add a new property, or replace an existing property- Parameters:
 newElement- The new property
 - 
addProperty
Convenience method create and then add a new property to this auth objectFor example, to add the following JSON property to the array of properties:
{ "key": "realm", "value": "testoauth@test.com", "type": "string" }authObj.setProperty("realm","somerealm@foo.com")Note that the type property always defaults to "string"- Parameters:
 key- The key for the new propertyvalue- The value for the new property
 
 -