ory-am/hydra

View on GitHub
internal/httpclient/model_introspected_o_auth2_token.go

Summary

Maintainability
C
1 day
Test Coverage
/*
Ory Hydra API

Documentation for all of Ory Hydra's APIs.

API version:
Contact: hi@ory.sh
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package openapi

import (
    "bytes"
    "encoding/json"
    "fmt"
)

// checks if the IntrospectedOAuth2Token type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &IntrospectedOAuth2Token{}

// IntrospectedOAuth2Token Introspection contains an access token's session data as specified by [IETF RFC 7662](https://tools.ietf.org/html/rfc7662)
type IntrospectedOAuth2Token struct {
    // Active is a boolean indicator of whether or not the presented token is currently active.  The specifics of a token's \"active\" state will vary depending on the implementation of the authorization server and the information it keeps about its tokens, but a \"true\" value return for the \"active\" property will generally indicate that a given token has been issued by this authorization server, has not been revoked by the resource owner, and is within its given time window of validity (e.g., after its issuance time and before its expiration time).
    Active bool `json:"active"`
    // Audience contains a list of the token's intended audiences.
    Aud []string `json:"aud,omitempty"`
    // ID is aclient identifier for the OAuth 2.0 client that requested this token.
    ClientId *string `json:"client_id,omitempty"`
    // Expires at is an integer timestamp, measured in the number of seconds since January 1 1970 UTC, indicating when this token will expire.
    Exp *int64 `json:"exp,omitempty"`
    // Extra is arbitrary data set by the session.
    Ext map[string]interface{} `json:"ext,omitempty"`
    // Issued at is an integer timestamp, measured in the number of seconds since January 1 1970 UTC, indicating when this token was originally issued.
    Iat *int64 `json:"iat,omitempty"`
    // IssuerURL is a string representing the issuer of this token
    Iss *string `json:"iss,omitempty"`
    // NotBefore is an integer timestamp, measured in the number of seconds since January 1 1970 UTC, indicating when this token is not to be used before.
    Nbf *int64 `json:"nbf,omitempty"`
    // ObfuscatedSubject is set when the subject identifier algorithm was set to \"pairwise\" during authorization. It is the `sub` value of the ID Token that was issued.
    ObfuscatedSubject *string `json:"obfuscated_subject,omitempty"`
    // Scope is a JSON string containing a space-separated list of scopes associated with this token.
    Scope *string `json:"scope,omitempty"`
    // Subject of the token, as defined in JWT [RFC7519]. Usually a machine-readable identifier of the resource owner who authorized this token.
    Sub *string `json:"sub,omitempty"`
    // TokenType is the introspected token's type, typically `Bearer`.
    TokenType *string `json:"token_type,omitempty"`
    // TokenUse is the introspected token's use, for example `access_token` or `refresh_token`.
    TokenUse *string `json:"token_use,omitempty"`
    // Username is a human-readable identifier for the resource owner who authorized this token.
    Username *string `json:"username,omitempty"`
}

type _IntrospectedOAuth2Token IntrospectedOAuth2Token

// NewIntrospectedOAuth2Token instantiates a new IntrospectedOAuth2Token object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewIntrospectedOAuth2Token(active bool) *IntrospectedOAuth2Token {
    this := IntrospectedOAuth2Token{}
    this.Active = active
    return &this
}

// NewIntrospectedOAuth2TokenWithDefaults instantiates a new IntrospectedOAuth2Token object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewIntrospectedOAuth2TokenWithDefaults() *IntrospectedOAuth2Token {
    this := IntrospectedOAuth2Token{}
    return &this
}

// GetActive returns the Active field value
func (o *IntrospectedOAuth2Token) GetActive() bool {
    if o == nil {
        var ret bool
        return ret
    }

    return o.Active
}

// GetActiveOk returns a tuple with the Active field value
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetActiveOk() (*bool, bool) {
    if o == nil {
        return nil, false
    }
    return &o.Active, true
}

// SetActive sets field value
func (o *IntrospectedOAuth2Token) SetActive(v bool) {
    o.Active = v
}

// GetAud returns the Aud field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetAud() []string {
    if o == nil || IsNil(o.Aud) {
        var ret []string
        return ret
    }
    return o.Aud
}

// GetAudOk returns a tuple with the Aud field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetAudOk() ([]string, bool) {
    if o == nil || IsNil(o.Aud) {
        return nil, false
    }
    return o.Aud, true
}

// HasAud returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasAud() bool {
    if o != nil && !IsNil(o.Aud) {
        return true
    }

    return false
}

// SetAud gets a reference to the given []string and assigns it to the Aud field.
func (o *IntrospectedOAuth2Token) SetAud(v []string) {
    o.Aud = v
}

// GetClientId returns the ClientId field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetClientId() string {
    if o == nil || IsNil(o.ClientId) {
        var ret string
        return ret
    }
    return *o.ClientId
}

// GetClientIdOk returns a tuple with the ClientId field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetClientIdOk() (*string, bool) {
    if o == nil || IsNil(o.ClientId) {
        return nil, false
    }
    return o.ClientId, true
}

// HasClientId returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasClientId() bool {
    if o != nil && !IsNil(o.ClientId) {
        return true
    }

    return false
}

// SetClientId gets a reference to the given string and assigns it to the ClientId field.
func (o *IntrospectedOAuth2Token) SetClientId(v string) {
    o.ClientId = &v
}

// GetExp returns the Exp field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetExp() int64 {
    if o == nil || IsNil(o.Exp) {
        var ret int64
        return ret
    }
    return *o.Exp
}

// GetExpOk returns a tuple with the Exp field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetExpOk() (*int64, bool) {
    if o == nil || IsNil(o.Exp) {
        return nil, false
    }
    return o.Exp, true
}

// HasExp returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasExp() bool {
    if o != nil && !IsNil(o.Exp) {
        return true
    }

    return false
}

// SetExp gets a reference to the given int64 and assigns it to the Exp field.
func (o *IntrospectedOAuth2Token) SetExp(v int64) {
    o.Exp = &v
}

// GetExt returns the Ext field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetExt() map[string]interface{} {
    if o == nil || IsNil(o.Ext) {
        var ret map[string]interface{}
        return ret
    }
    return o.Ext
}

// GetExtOk returns a tuple with the Ext field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetExtOk() (map[string]interface{}, bool) {
    if o == nil || IsNil(o.Ext) {
        return map[string]interface{}{}, false
    }
    return o.Ext, true
}

// HasExt returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasExt() bool {
    if o != nil && !IsNil(o.Ext) {
        return true
    }

    return false
}

// SetExt gets a reference to the given map[string]interface{} and assigns it to the Ext field.
func (o *IntrospectedOAuth2Token) SetExt(v map[string]interface{}) {
    o.Ext = v
}

// GetIat returns the Iat field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetIat() int64 {
    if o == nil || IsNil(o.Iat) {
        var ret int64
        return ret
    }
    return *o.Iat
}

// GetIatOk returns a tuple with the Iat field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetIatOk() (*int64, bool) {
    if o == nil || IsNil(o.Iat) {
        return nil, false
    }
    return o.Iat, true
}

// HasIat returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasIat() bool {
    if o != nil && !IsNil(o.Iat) {
        return true
    }

    return false
}

// SetIat gets a reference to the given int64 and assigns it to the Iat field.
func (o *IntrospectedOAuth2Token) SetIat(v int64) {
    o.Iat = &v
}

// GetIss returns the Iss field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetIss() string {
    if o == nil || IsNil(o.Iss) {
        var ret string
        return ret
    }
    return *o.Iss
}

// GetIssOk returns a tuple with the Iss field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetIssOk() (*string, bool) {
    if o == nil || IsNil(o.Iss) {
        return nil, false
    }
    return o.Iss, true
}

// HasIss returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasIss() bool {
    if o != nil && !IsNil(o.Iss) {
        return true
    }

    return false
}

// SetIss gets a reference to the given string and assigns it to the Iss field.
func (o *IntrospectedOAuth2Token) SetIss(v string) {
    o.Iss = &v
}

// GetNbf returns the Nbf field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetNbf() int64 {
    if o == nil || IsNil(o.Nbf) {
        var ret int64
        return ret
    }
    return *o.Nbf
}

// GetNbfOk returns a tuple with the Nbf field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetNbfOk() (*int64, bool) {
    if o == nil || IsNil(o.Nbf) {
        return nil, false
    }
    return o.Nbf, true
}

// HasNbf returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasNbf() bool {
    if o != nil && !IsNil(o.Nbf) {
        return true
    }

    return false
}

// SetNbf gets a reference to the given int64 and assigns it to the Nbf field.
func (o *IntrospectedOAuth2Token) SetNbf(v int64) {
    o.Nbf = &v
}

// GetObfuscatedSubject returns the ObfuscatedSubject field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetObfuscatedSubject() string {
    if o == nil || IsNil(o.ObfuscatedSubject) {
        var ret string
        return ret
    }
    return *o.ObfuscatedSubject
}

// GetObfuscatedSubjectOk returns a tuple with the ObfuscatedSubject field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetObfuscatedSubjectOk() (*string, bool) {
    if o == nil || IsNil(o.ObfuscatedSubject) {
        return nil, false
    }
    return o.ObfuscatedSubject, true
}

// HasObfuscatedSubject returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasObfuscatedSubject() bool {
    if o != nil && !IsNil(o.ObfuscatedSubject) {
        return true
    }

    return false
}

// SetObfuscatedSubject gets a reference to the given string and assigns it to the ObfuscatedSubject field.
func (o *IntrospectedOAuth2Token) SetObfuscatedSubject(v string) {
    o.ObfuscatedSubject = &v
}

// GetScope returns the Scope field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetScope() string {
    if o == nil || IsNil(o.Scope) {
        var ret string
        return ret
    }
    return *o.Scope
}

// GetScopeOk returns a tuple with the Scope field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetScopeOk() (*string, bool) {
    if o == nil || IsNil(o.Scope) {
        return nil, false
    }
    return o.Scope, true
}

// HasScope returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasScope() bool {
    if o != nil && !IsNil(o.Scope) {
        return true
    }

    return false
}

// SetScope gets a reference to the given string and assigns it to the Scope field.
func (o *IntrospectedOAuth2Token) SetScope(v string) {
    o.Scope = &v
}

// GetSub returns the Sub field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetSub() string {
    if o == nil || IsNil(o.Sub) {
        var ret string
        return ret
    }
    return *o.Sub
}

// GetSubOk returns a tuple with the Sub field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetSubOk() (*string, bool) {
    if o == nil || IsNil(o.Sub) {
        return nil, false
    }
    return o.Sub, true
}

// HasSub returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasSub() bool {
    if o != nil && !IsNil(o.Sub) {
        return true
    }

    return false
}

// SetSub gets a reference to the given string and assigns it to the Sub field.
func (o *IntrospectedOAuth2Token) SetSub(v string) {
    o.Sub = &v
}

// GetTokenType returns the TokenType field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetTokenType() string {
    if o == nil || IsNil(o.TokenType) {
        var ret string
        return ret
    }
    return *o.TokenType
}

// GetTokenTypeOk returns a tuple with the TokenType field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetTokenTypeOk() (*string, bool) {
    if o == nil || IsNil(o.TokenType) {
        return nil, false
    }
    return o.TokenType, true
}

// HasTokenType returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasTokenType() bool {
    if o != nil && !IsNil(o.TokenType) {
        return true
    }

    return false
}

// SetTokenType gets a reference to the given string and assigns it to the TokenType field.
func (o *IntrospectedOAuth2Token) SetTokenType(v string) {
    o.TokenType = &v
}

// GetTokenUse returns the TokenUse field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetTokenUse() string {
    if o == nil || IsNil(o.TokenUse) {
        var ret string
        return ret
    }
    return *o.TokenUse
}

// GetTokenUseOk returns a tuple with the TokenUse field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetTokenUseOk() (*string, bool) {
    if o == nil || IsNil(o.TokenUse) {
        return nil, false
    }
    return o.TokenUse, true
}

// HasTokenUse returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasTokenUse() bool {
    if o != nil && !IsNil(o.TokenUse) {
        return true
    }

    return false
}

// SetTokenUse gets a reference to the given string and assigns it to the TokenUse field.
func (o *IntrospectedOAuth2Token) SetTokenUse(v string) {
    o.TokenUse = &v
}

// GetUsername returns the Username field value if set, zero value otherwise.
func (o *IntrospectedOAuth2Token) GetUsername() string {
    if o == nil || IsNil(o.Username) {
        var ret string
        return ret
    }
    return *o.Username
}

// GetUsernameOk returns a tuple with the Username field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *IntrospectedOAuth2Token) GetUsernameOk() (*string, bool) {
    if o == nil || IsNil(o.Username) {
        return nil, false
    }
    return o.Username, true
}

// HasUsername returns a boolean if a field has been set.
func (o *IntrospectedOAuth2Token) HasUsername() bool {
    if o != nil && !IsNil(o.Username) {
        return true
    }

    return false
}

// SetUsername gets a reference to the given string and assigns it to the Username field.
func (o *IntrospectedOAuth2Token) SetUsername(v string) {
    o.Username = &v
}

func (o IntrospectedOAuth2Token) MarshalJSON() ([]byte, error) {
    toSerialize, err := o.ToMap()
    if err != nil {
        return []byte{}, err
    }
    return json.Marshal(toSerialize)
}

func (o IntrospectedOAuth2Token) ToMap() (map[string]interface{}, error) {
    toSerialize := map[string]interface{}{}
    toSerialize["active"] = o.Active
    if !IsNil(o.Aud) {
        toSerialize["aud"] = o.Aud
    }
    if !IsNil(o.ClientId) {
        toSerialize["client_id"] = o.ClientId
    }
    if !IsNil(o.Exp) {
        toSerialize["exp"] = o.Exp
    }
    if !IsNil(o.Ext) {
        toSerialize["ext"] = o.Ext
    }
    if !IsNil(o.Iat) {
        toSerialize["iat"] = o.Iat
    }
    if !IsNil(o.Iss) {
        toSerialize["iss"] = o.Iss
    }
    if !IsNil(o.Nbf) {
        toSerialize["nbf"] = o.Nbf
    }
    if !IsNil(o.ObfuscatedSubject) {
        toSerialize["obfuscated_subject"] = o.ObfuscatedSubject
    }
    if !IsNil(o.Scope) {
        toSerialize["scope"] = o.Scope
    }
    if !IsNil(o.Sub) {
        toSerialize["sub"] = o.Sub
    }
    if !IsNil(o.TokenType) {
        toSerialize["token_type"] = o.TokenType
    }
    if !IsNil(o.TokenUse) {
        toSerialize["token_use"] = o.TokenUse
    }
    if !IsNil(o.Username) {
        toSerialize["username"] = o.Username
    }
    return toSerialize, nil
}

func (o *IntrospectedOAuth2Token) UnmarshalJSON(data []byte) (err error) {
    // This validates that all required properties are included in the JSON object
    // by unmarshalling the object into a generic map with string keys and checking
    // that every required field exists as a key in the generic map.
    requiredProperties := []string{
        "active",
    }

    allProperties := make(map[string]interface{})

    err = json.Unmarshal(data, &allProperties)

    if err != nil {
        return err
    }

    for _, requiredProperty := range requiredProperties {
        if _, exists := allProperties[requiredProperty]; !exists {
            return fmt.Errorf("no value given for required property %v", requiredProperty)
        }
    }

    varIntrospectedOAuth2Token := _IntrospectedOAuth2Token{}

    decoder := json.NewDecoder(bytes.NewReader(data))
    decoder.DisallowUnknownFields()
    err = decoder.Decode(&varIntrospectedOAuth2Token)

    if err != nil {
        return err
    }

    *o = IntrospectedOAuth2Token(varIntrospectedOAuth2Token)

    return err
}

type NullableIntrospectedOAuth2Token struct {
    value *IntrospectedOAuth2Token
    isSet bool
}

func (v NullableIntrospectedOAuth2Token) Get() *IntrospectedOAuth2Token {
    return v.value
}

func (v *NullableIntrospectedOAuth2Token) Set(val *IntrospectedOAuth2Token) {
    v.value = val
    v.isSet = true
}

func (v NullableIntrospectedOAuth2Token) IsSet() bool {
    return v.isSet
}

func (v *NullableIntrospectedOAuth2Token) Unset() {
    v.value = nil
    v.isSet = false
}

func NewNullableIntrospectedOAuth2Token(val *IntrospectedOAuth2Token) *NullableIntrospectedOAuth2Token {
    return &NullableIntrospectedOAuth2Token{value: val, isSet: true}
}

func (v NullableIntrospectedOAuth2Token) MarshalJSON() ([]byte, error) {
    return json.Marshal(v.value)
}

func (v *NullableIntrospectedOAuth2Token) UnmarshalJSON(src []byte) error {
    v.isSet = true
    return json.Unmarshal(src, &v.value)
}