sideko_rest_api 0.9.2

Rust API Client
Documentation
# role

## Module Functions

### Delete Role <a name="delete"></a>

**API Endpoint**: `DELETE /role/{id}`

#### Parameters

| Parameter | Required | Description | Example                                              |
| --------- | :------: | ----------- | ---------------------------------------------------- |
| `id`      |    ✓     |             | `"3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string()` |

#### Example Snippet

```rust
let client = sideko_rest_api::SidekoClient::default()
    .with_api_key_auth(&std::env::var("API_KEY").unwrap())
    .with_cookie_auth(&std::env::var("API_KEY").unwrap());
let res = client
    .role()
    .delete(sideko_rest_api::resources::role::DeleteRequest {
        id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(),
    })
    .await;
```

### List Roles <a name="list"></a>

**API Endpoint**: `GET /role`

#### Parameters

| Parameter     | Required | Description               | Example                                              |
| ------------- | :------: | ------------------------- | ---------------------------------------------------- |
| `object_id`   |    ✗     | filter roles by object id | `"3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string()` |
| `object_type` |    ✗     |                           | `ObjectTypeEnum::ApiProject`                         |
| `user_id`     |    ✗     | filter roles by user id   | `"3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string()` |

#### Example Snippet

```rust
let client = sideko_rest_api::SidekoClient::default()
    .with_api_key_auth(&std::env::var("API_KEY").unwrap())
    .with_cookie_auth(&std::env::var("API_KEY").unwrap());
let res = client
    .role()
    .list(sideko_rest_api::resources::role::ListRequest {
        ..Default::default()
    })
    .await;
```

#### Response

##### Type

Vec of [Role](/src/models/role.rs)

##### Example

```rust
vec![Role {definition: RoleDefinition {actions: vec![ActionEnum::ApiProjectDelete], display_name: "Org Admin".to_string(), id: RoleDefinitionIdEnum::ApiProjectAdmin}, id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(), object_id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(), object_type: ObjectTypeEnum::ApiProject, user: User {avatar_url: "http://www.example.com".to_string(), created_at: "1970-01-01T00:00:00".to_string(), email: "mail@example.com".to_string(), expiration: Some("1970-01-01T00:00:00".to_string()), first_name: "string".to_string(), id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(), is_service_account: true, last_name: "string".to_string()}}]
```

### Create New Role <a name="create"></a>

**API Endpoint**: `POST /role`

#### Parameters

| Parameter            | Required | Description                                                     | Example                                              |
| -------------------- | :------: | --------------------------------------------------------------- | ---------------------------------------------------- |
| `object_id`          |    ✓     | The unique identifier of the Sideko object                      | `"3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string()` |
| `object_type`        |    ✓     |                                                                 | `ObjectTypeEnum::ApiProject`                         |
| `role_definition_id` |    ✓     |                                                                 | `RoleDefinitionIdEnum::ApiProjectAdmin`              |
| `user_id`            |    ✓     | unique identifier for the user that the role will be granted to | `"3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string()` |

#### Example Snippet

```rust
let client = sideko_rest_api::SidekoClient::default()
    .with_api_key_auth(&std::env::var("API_KEY").unwrap())
    .with_cookie_auth(&std::env::var("API_KEY").unwrap());
let res = client
    .role()
    .create(sideko_rest_api::resources::role::CreateRequest {
        object_id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(),
        object_type: sideko_rest_api::models::ObjectTypeEnum::ApiProject,
        role_definition_id: sideko_rest_api::models::RoleDefinitionIdEnum::ApiProjectAdmin,
        user_id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(),
    })
    .await;
```

#### Response

##### Type

[Role](/src/models/role.rs)

##### Example

```rust
Role {definition: RoleDefinition {actions: vec![ActionEnum::ApiProjectDelete], display_name: "Org Admin".to_string(), id: RoleDefinitionIdEnum::ApiProjectAdmin}, id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(), object_id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(), object_type: ObjectTypeEnum::ApiProject, user: User {avatar_url: "http://www.example.com".to_string(), created_at: "1970-01-01T00:00:00".to_string(), email: "mail@example.com".to_string(), expiration: Some("1970-01-01T00:00:00".to_string()), first_name: "string".to_string(), id: "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a".to_string(), is_service_account: true, last_name: "string".to_string()}}
```