Documentation ¶
Index ¶
- Variables
- func CacheExpires(r *http.Response) time.Time
- type APIClient
- type APIKey
- type APIResponse
- type BasicAuth
- type Configuration
- type Error
- type GenericOpenAPIError
- type IssueTokenRequest
- type LoginRequest
- type ResetPasswordOpts
- type ResetPasswordRequest
- type ServerConfiguration
- type ServerVariable
- type TokenResponse
- type User
- type UserMeta
- type UsersApiService
- func (a *UsersApiService) CreateUser(ctx _context.Context, user User) (User, *_nethttp.Response, error)
- func (a *UsersApiService) DeleteUser(ctx _context.Context, username string) (User, *_nethttp.Response, error)
- func (a *UsersApiService) GetUser(ctx _context.Context, username string) (User, *_nethttp.Response, error)
- func (a *UsersApiService) GetUserByID(ctx _context.Context, uid int32) (User, *_nethttp.Response, error)
- func (a *UsersApiService) GetUsers(ctx _context.Context) ([]User, *_nethttp.Response, error)
- func (a *UsersApiService) IssueToken(ctx _context.Context, username string, issueTokenRequest IssueTokenRequest) (TokenResponse, *_nethttp.Response, error)
- func (a *UsersApiService) Login(ctx _context.Context, username string, loginRequest LoginRequest) (TokenResponse, *_nethttp.Response, error)
- func (a *UsersApiService) Logout(ctx _context.Context, username string) (*_nethttp.Response, error)
- func (a *UsersApiService) ResetPassword(ctx _context.Context, username string, localVarOptionals *ResetPasswordOpts) (*_nethttp.Response, error)
- func (a *UsersApiService) UpdateUser(ctx _context.Context, username string, user User) (User, *_nethttp.Response, error)
- func (a *UsersApiService) ValidateToken(ctx _context.Context) (*_nethttp.Response, error)
- func (a *UsersApiService) Verify(ctx _context.Context, username string) (*_nethttp.Response, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") )
Functions ¶
Types ¶
type APIClient ¶
type APIClient struct { UsersApi *UsersApiService // contains filtered or unexported fields }
APIClient manages communication with the Netsoc IAM API v1.0.11 In most cases there should be only one, shared, APIClient.
func NewAPIClient ¶
func NewAPIClient(cfg *Configuration) *APIClient
NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.
func (*APIClient) ChangeBasePath ¶
ChangeBasePath changes base path to allow switching to mocks
func (*APIClient) GetConfig ¶
func (c *APIClient) GetConfig() *Configuration
Allow modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
type APIKey ¶
APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIResponse ¶
type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the OpenAPI operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` }
APIResponse stores the API response returned by the server.
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
NewAPIResponse returns a new APIResonse object.
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
type BasicAuth ¶
type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` }
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type Configuration ¶
type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` Debug bool `json:"debug,omitempty"` Servers []ServerConfiguration HTTPClient *http.Client }
Configuration stores the configuration of the API client
func NewConfiguration ¶
func NewConfiguration() *Configuration
NewConfiguration returns a new Configuration object
func (*Configuration) AddDefaultHeader ¶
func (c *Configuration) AddDefaultHeader(key string, value string)
AddDefaultHeader adds a new HTTP header to the default header in the request
type Error ¶
type Error struct { // Message explaining the error Message string `json:"message"` }
Error struct for Error
type GenericOpenAPIError ¶
type GenericOpenAPIError struct {
// contains filtered or unexported fields
}
GenericOpenAPIError Provides access to the body, error and model on returned errors.
func (GenericOpenAPIError) Body ¶
func (e GenericOpenAPIError) Body() []byte
Body returns the raw bytes of the response
func (GenericOpenAPIError) Error ¶
func (e GenericOpenAPIError) Error() string
Error returns non-empty string if there was an error.
func (GenericOpenAPIError) Model ¶
func (e GenericOpenAPIError) Model() interface{}
Model returns the unpacked model of the error
type IssueTokenRequest ¶
type IssueTokenRequest struct { // Duration of validity for token. Follows [Go's `time.Duration` format](https://pkg.go.dev/time#ParseDuration) Duration string `json:"duration,omitempty"` }
IssueTokenRequest struct for IssueTokenRequest
type LoginRequest ¶
type LoginRequest struct {
Password string `json:"password"`
}
LoginRequest struct for LoginRequest
type ResetPasswordOpts ¶
ResetPasswordOpts Optional parameters for the method 'ResetPassword'
type ResetPasswordRequest ¶
type ResetPasswordRequest struct {
Password string `json:"password,omitempty"`
}
ResetPasswordRequest struct for ResetPasswordRequest
type ServerConfiguration ¶
type ServerConfiguration struct { Url string Description string Variables map[string]ServerVariable }
ServerConfiguration stores the information about a server
type ServerVariable ¶
ServerVariable stores the information about a server variable
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token,omitempty"`
}
TokenResponse struct for TokenResponse
type User ¶
type User struct { // Unique database identifier, not modifiable. Id int32 `json:"id"` // Unique username (must be a valid DNS name) Username string `json:"username"` // Unique email address (must be `@tcd.ie`) Email string `json:"email"` // Stored internally as a bcrypt hash. If unset, login will be disabled. Password *string `json:"password,omitempty"` FirstName string `json:"first_name"` LastName string `json:"last_name"` // SSH public key SshKey *string `json:"ssh_key,omitempty"` // Indicates if the user's email address is verified. Only modifiable directly by an admin. Verified *bool `json:"verified,omitempty"` // Indicates if the user is an admin. Only modifiable by an admin. IsAdmin *bool `json:"is_admin,omitempty"` // Date and time when the user's membership was last renewed. Only modifiable by an admin. Renewed time.Time `json:"renewed,omitempty"` Meta UserMeta `json:"meta,omitempty"` }
User struct for User
type UserMeta ¶
type UserMeta struct { // Date and time at which the user was created Created time.Time `json:"created"` // Date and time at which the user was last updated Updated time.Time `json:"updated"` }
UserMeta Metadata about the user, not modifiable.
type UsersApiService ¶
type UsersApiService service
UsersApiService UsersApi service
func (*UsersApiService) CreateUser ¶
func (a *UsersApiService) CreateUser(ctx _context.Context, user User) (User, *_nethttp.Response, error)
CreateUser Create a new user A verification email will automatically be sent to the user's email address. Normally this just contains the raw JWT - setting `Accept` to contain `text/html` will send an email with a link to the configured UI service and the token.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param user User to create
@return User
func (*UsersApiService) DeleteUser ¶
func (a *UsersApiService) DeleteUser(ctx _context.Context, username string) (User, *_nethttp.Response, error)
DeleteUser Delete a user by their username Requires at least an expired user JWT. A valid admin JWT is required to delete a user other than `self`.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
@return User
func (*UsersApiService) GetUser ¶
func (a *UsersApiService) GetUser(ctx _context.Context, username string) (User, *_nethttp.Response, error)
GetUser Get a user by their username Requires at least an expired user JWT. A valid admin JWT is required to retrieve a user other than `self`.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
@return User
func (*UsersApiService) GetUserByID ¶ added in v1.0.8
func (a *UsersApiService) GetUserByID(ctx _context.Context, uid int32) (User, *_nethttp.Response, error)
GetUserByID Get a user by their ID Requires a valid admin JWT.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param uid User ID
@return User
func (*UsersApiService) GetUsers ¶
GetUsers List users
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return []User
func (*UsersApiService) IssueToken ¶
func (a *UsersApiService) IssueToken(ctx _context.Context, username string, issueTokenRequest IssueTokenRequest) (TokenResponse, *_nethttp.Response, error)
IssueToken Issue a token
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username.
- @param issueTokenRequest
@return TokenResponse
func (*UsersApiService) Login ¶
func (a *UsersApiService) Login(ctx _context.Context, username string, loginRequest LoginRequest) (TokenResponse, *_nethttp.Response, error)
Login Log into a user account (obtain JWT)
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username.
- @param loginRequest
@return TokenResponse
func (*UsersApiService) Logout ¶
Logout Log out of a user account (invalidate existing JWT's) Requires at least an expired user JWT. A valid admin JWT is required to logout a user other than `self`.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
func (*UsersApiService) ResetPassword ¶
func (a *UsersApiService) ResetPassword(ctx _context.Context, username string, localVarOptionals *ResetPasswordOpts) (*_nethttp.Response, error)
ResetPassword Reset password Making a request without a token (or request body) will generate a token and send it to the user's email address. Normally this just contains the raw JWT - setting `Accept` to contain `text/html` will send an email with a link to the configured UI service and the token. Passing the returned token to this endpoint (along with the new password) will perform the reset.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param optional nil or *ResetPasswordOpts - Optional Parameters:
- @param "ResetPasswordRequest" (optional.Interface of ResetPasswordRequest) -
func (*UsersApiService) UpdateUser ¶
func (a *UsersApiService) UpdateUser(ctx _context.Context, username string, user User) (User, *_nethttp.Response, error)
UpdateUser Update a user by their username Requires at least an expired user JWT. A valid admin JWT is required to update admin-only fields and modify a user other than `self`. A verification email will automatically be sent to the user's email address if it has been changed. Normally this just contains the raw JWT - setting `Accept` to contain `text/html` will send an email with a link to the configured UI service and the token.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param user Partial user containing fields to update
@return User
func (*UsersApiService) ValidateToken ¶
ValidateToken Validate a token
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
func (*UsersApiService) Verify ¶
Verify Verify email address Making a request without a token will generate a token and send it to the user's email address. Normally this just contains the raw JWT - setting `Accept` to contain `text/html` will send an email with a link to the configured UI service and the token. Passing the returned token to this endpoint will perform the verification.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.