# User

## Get User Details

`client.User.Get(ctx) (*User, error)`

**get** `/v1/user`

Get details about an authenticated user

### Returns

- `type User struct{…}`

  User details.

  - `ID string`

    Unique identifier for the User.

  - `Email string`

    Email address of the user.

  - `FirstName string`

    First name of the user.

  - `LastName string`

    Last name of the user.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  user, err := client.User.Get(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", user.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "email": "satoshi@nirvanalabs.io",
  "first_name": "Satoshi",
  "last_name": "Nakamoto"
}
```

## Domain Types

### User

- `type User struct{…}`

  User details.

  - `ID string`

    Unique identifier for the User.

  - `Email string`

    Email address of the user.

  - `FirstName string`

    First name of the user.

  - `LastName string`

    Last name of the user.

# Security

## Get User Security Settings

`client.User.Security.Get(ctx) (*UserSecurity, error)`

**get** `/v1/user/security`

Get the current user's security settings

### Returns

- `type UserSecurity struct{…}`

  User security settings response.

  - `SourceIPRule SourceIPRuleResponse`

    IP filter rules.

    - `Allowed []string`

      List of IPv4 CIDR addresses to allow.

    - `Blocked []string`

      List of IPv4 CIDR addresses to deny.

  - `CreatedAt Time`

    When the user security settings were created.

  - `UpdatedAt Time`

    When the user security settings were updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  userSecurity, err := client.User.Security.Get(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", userSecurity.SourceIPRule)
}
```

#### Response

```json
{
  "source_ip_rule": {
    "allowed": [
      "192.168.1.0/24",
      "10.0.0.0/8"
    ],
    "blocked": [
      "192.168.1.100/32"
    ]
  },
  "created_at": "2025-01-01T00:00:00Z",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Update User Security Settings

`client.User.Security.Update(ctx, body) (*UserSecurity, error)`

**patch** `/v1/user/security`

Update the current user's security settings

### Parameters

- `body SecurityUpdateParams`

  - `SourceIPRule param.Field[SourceIPRule]`

    IP filter rules.

### Returns

- `type UserSecurity struct{…}`

  User security settings response.

  - `SourceIPRule SourceIPRuleResponse`

    IP filter rules.

    - `Allowed []string`

      List of IPv4 CIDR addresses to allow.

    - `Blocked []string`

      List of IPv4 CIDR addresses to deny.

  - `CreatedAt Time`

    When the user security settings were created.

  - `UpdatedAt Time`

    When the user security settings were updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/user"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  userSecurity, err := client.User.Security.Update(context.TODO(), user.SecurityUpdateParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", userSecurity.SourceIPRule)
}
```

#### Response

```json
{
  "source_ip_rule": {
    "allowed": [
      "192.168.1.0/24",
      "10.0.0.0/8"
    ],
    "blocked": [
      "192.168.1.100/32"
    ]
  },
  "created_at": "2025-01-01T00:00:00Z",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Domain Types

### User Security

- `type UserSecurity struct{…}`

  User security settings response.

  - `SourceIPRule SourceIPRuleResponse`

    IP filter rules.

    - `Allowed []string`

      List of IPv4 CIDR addresses to allow.

    - `Blocked []string`

      List of IPv4 CIDR addresses to deny.

  - `CreatedAt Time`

    When the user security settings were created.

  - `UpdatedAt Time`

    When the user security settings were updated.
