Skip to content

Latest commit

 

History

History
484 lines (311 loc) · 14.7 KB

UserAPI.md

File metadata and controls

484 lines (311 loc) · 14.7 KB

UserAPI

Note

All URIs are relative to https://api.fastly.com

Method HTTP request Description
CreateUser POST /user Create a user
DeleteUser DELETE /user/{user_id} Delete a user
GetCurrentUser GET /current_user Get the current user
GetUser GET /user/{user_id} Get a user
RequestPasswordReset POST /user/{user_login}/password/request_reset Request a password reset
UpdateUser PUT /user/{user_id} Update a user
UpdateUserPassword POST /current_user/password Update the user's password

CreateUser

Create a user

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    login := "login_example" // string |  (optional)
    name := "name_example" // string | The real life name of the user. (optional)
    limitServices := true // bool | Indicates that the user has limited access to the customer's services. (optional)
    locked := true // bool | Indicates whether the is account is locked for editing or not. (optional)
    requireNewPassword := true // bool | Indicates if a new password is required at next login. (optional)
    role := openapiclient.role_user("user") // RoleUser |  (optional)
    twoFactorAuthEnabled := true // bool | Indicates if 2FA is enabled on the user. (optional)
    twoFactorSetupRequired := true // bool | Indicates if 2FA is required by the user's customer account. (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.UserAPI.CreateUser(ctx).Login(login).Name(name).LimitServices(limitServices).Locked(locked).RequireNewPassword(requireNewPassword).Role(role).TwoFactorAuthEnabled(twoFactorAuthEnabled).TwoFactorSetupRequired(twoFactorSetupRequired).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `UserAPI.CreateUser`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateUser`: UserResponse
    fmt.Fprintf(os.Stdout, "Response from `UserAPI.CreateUser`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiCreateUserRequest struct via the builder pattern

Name Type Description Notes
login string name

Return type

UserResponse

Authorization

API Token

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Back to top | Back to API list | Back to README

DeleteUser

Delete a user

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    userID := "userId_example" // string | Alphanumeric string identifying the user.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.UserAPI.DeleteUser(ctx, userID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `UserAPI.DeleteUser`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `DeleteUser`: InlineResponse200
    fmt.Fprintf(os.Stdout, "Response from `UserAPI.DeleteUser`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
userID string Alphanumeric string identifying the user.

Other Parameters

Other parameters are passed through a pointer to a apiDeleteUserRequest struct via the builder pattern

Name Type Description Notes

Return type

InlineResponse200

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

GetCurrentUser

Get the current user

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.UserAPI.GetCurrentUser(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `UserAPI.GetCurrentUser`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetCurrentUser`: UserResponse
    fmt.Fprintf(os.Stdout, "Response from `UserAPI.GetCurrentUser`: %v\n", resp)
}

Path Parameters

This endpoint does not need any parameter.

Other Parameters

Other parameters are passed through a pointer to a apiGetCurrentUserRequest struct via the builder pattern

Return type

UserResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

GetUser

Get a user

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    userID := "userId_example" // string | Alphanumeric string identifying the user.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.UserAPI.GetUser(ctx, userID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `UserAPI.GetUser`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetUser`: UserResponse
    fmt.Fprintf(os.Stdout, "Response from `UserAPI.GetUser`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
userID string Alphanumeric string identifying the user.

Other Parameters

Other parameters are passed through a pointer to a apiGetUserRequest struct via the builder pattern

Name Type Description Notes

Return type

UserResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

RequestPasswordReset

Request a password reset

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    userLogin := "userLogin_example" // string | The login associated with the user (typically, an email address).

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.UserAPI.RequestPasswordReset(ctx, userLogin).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `UserAPI.RequestPasswordReset`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `RequestPasswordReset`: InlineResponse200
    fmt.Fprintf(os.Stdout, "Response from `UserAPI.RequestPasswordReset`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
userLogin string The login associated with the user (typically, an email address).

Other Parameters

Other parameters are passed through a pointer to a apiRequestPasswordResetRequest struct via the builder pattern

Name Type Description Notes

Return type

InlineResponse200

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

UpdateUser

Update a user

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    userID := "userId_example" // string | Alphanumeric string identifying the user.
    login := "login_example" // string |  (optional)
    name := "name_example" // string | The real life name of the user. (optional)
    limitServices := true // bool | Indicates that the user has limited access to the customer's services. (optional)
    locked := true // bool | Indicates whether the is account is locked for editing or not. (optional)
    requireNewPassword := true // bool | Indicates if a new password is required at next login. (optional)
    role := openapiclient.role_user("user") // RoleUser |  (optional)
    twoFactorAuthEnabled := true // bool | Indicates if 2FA is enabled on the user. (optional)
    twoFactorSetupRequired := true // bool | Indicates if 2FA is required by the user's customer account. (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.UserAPI.UpdateUser(ctx, userID).Login(login).Name(name).LimitServices(limitServices).Locked(locked).RequireNewPassword(requireNewPassword).Role(role).TwoFactorAuthEnabled(twoFactorAuthEnabled).TwoFactorSetupRequired(twoFactorSetupRequired).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `UserAPI.UpdateUser`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateUser`: UserResponse
    fmt.Fprintf(os.Stdout, "Response from `UserAPI.UpdateUser`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
userID string Alphanumeric string identifying the user.

Other Parameters

Other parameters are passed through a pointer to a apiUpdateUserRequest struct via the builder pattern

Name Type Description Notes
login string name

Return type

UserResponse

Authorization

API Token

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Back to top | Back to API list | Back to README

UpdateUserPassword

Update the user's password

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    oldPassword := "oldPassword_example" // string | The user's current password. (optional)
    newPassword := "newPassword_example" // string | The user's new password. (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.UserAPI.UpdateUserPassword(ctx).OldPassword(oldPassword).NewPassword(newPassword).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `UserAPI.UpdateUserPassword`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateUserPassword`: UserResponse
    fmt.Fprintf(os.Stdout, "Response from `UserAPI.UpdateUserPassword`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiUpdateUserPasswordRequest struct via the builder pattern

Name Type Description Notes
oldPassword string The user's current password. newPassword

Return type

UserResponse

Authorization

API Token

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Back to top | Back to API list | Back to README