Skip to content

Commit

Permalink
Merge pull request #4 from Authress/add-chrono-support
Browse files Browse the repository at this point in the history
Use chrono for datetimes.
  • Loading branch information
wparad authored Jan 10, 2024
2 parents 38ff60b + 668282c commit 737e4ce
Show file tree
Hide file tree
Showing 25 changed files with 94 additions and 62 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"cSpell.words": [
"chrono",
"permissioned",
"reqwest",
"urlencode"
Expand Down
59 changes: 40 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde"] }
reqwest = { version = "^0.11", features = ["json", "multipart"] }
chrono = { version = "0.4.31", features = ["serde"] }
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<p align="center">
<img src="https://github.com/Authress/authress-sdk.cs/assets/5056218/924fb776-9588-4d4a-adf7-33682fa29356" height="300px" alt="Authress Media Banner">
</p>

# Authress SDK for Rust

<p align="center">
<a href="https://crates.io/crates/authress" alt="Authress SDK on crates.io">
<img src="https://img.shields.io/crates/v/authress.svg">
</a>
<a href="https://authress.io/community" alt="authress community">
<img src="https://img.shields.io/badge/community-Discord-purple.svg">
</a>
<a href="https://github.com/Authress/authress-sdk.rs/actions" alt="GitHub action status">
<img src="https://github.com/authress/authress-sdk.rs/actions/workflows/build.yml/badge.svg">
</a>
<a href="https://crates.io/crates/authress" alt="Authress SDK on crates.io"><img src="https://img.shields.io/crates/v/authress.svg"></a>
<a href="./LICENSE" alt="Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a>
<a href="https://authress.io/community" alt="authress community"><img src="https://img.shields.io/badge/Community-Authress-fbaf0b.svg"></a>
<a href="https://github.com/Authress/authress-sdk.rs/actions" alt="GitHub action status"><img src="https://github.com/authress/authress-sdk.rs/actions/workflows/build.yml/badge.svg"></a>
</p>


Expand Down
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ podman stop $CID && podman rm $CID
* [ ] Validate all enums are enums and can be null when they should be.
* [ ] Remove LocalHost from the docs
* [ ] Tests
* [ ] If-unmodified-since should called `expectedLastModifiedTime`, accept string or dateTime and convert this to an ISO String
* [x] If-unmodified-since should called `expectedLastModifiedTime`, accept string or dateTime and convert this to an ISO String
2 changes: 1 addition & 1 deletion docs/AccessRecord.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name | Type | Description | Notes
**name** | **String** | A helpful name for this record |
**description** | Option<**String**> | More details about this record | [optional]
**capacity** | Option<**f32**> | Percentage capacity of record that is filled. | [optional][readonly]
**last_updated** | Option<**String**> | The expected last time the record was updated | [optional][readonly]
**last_updated** | Option<**DateTime**> | The expected last time the record was updated | [optional][readonly]
**status** | Option<**String**> | Current status of the access record. | [optional][readonly]
**users** | Option<Vec<**[crate::models::User](User.md)**>> | The list of users this record applies to | [optional]
**admins** | Option<Vec<**[crate::models::User](User.md)**>> | The list of admin that can edit this record even if they do not have global record edit permissions. | [optional]
Expand Down
4 changes: 2 additions & 2 deletions docs/AccessRecordsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Name | Type | Description | Required | Notes

## update_record

> update_record(record_id, access_record, expected_last_modified_time)
> update_record(record_id, access_record, { expected_last_modified_time })
Update access record

Updates an access record adding or removing user permissions to resources. (Records have a maximum size of ~100KB)
Expand All @@ -319,7 +319,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**record_id** | **String** | The identifier of the access record. | [required] |
**access_record** | [**AccessRecord**](AccessRecord.md) | | [required] |
**expected_last_modified_time** | Option<**String**> | The expected last time the record was modified. | |
**expected_last_modified_time** | Option<**DateTime**> | The expected last time the record was modified. | |

### Return type

Expand Down
2 changes: 1 addition & 1 deletion docs/AccessRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**request_id** | **String** | Unique identifier for the request. | [readonly]
**last_updated** | Option<**String**> | The expected last time the request was updated | [optional][readonly]
**last_updated** | Option<**DateTime**> | The expected last time the request was updated | [optional][readonly]
**status** | Option<**String**> | Current status of the access request. | [optional][readonly]
**access** | [**crate::models::AccessTemplate**](AccessTemplate.md) | |
**links** | Option<[**crate::models::Links**](Links.md)> | |
Expand Down
2 changes: 1 addition & 1 deletion docs/Account.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**account_id** | **String** | |
**created_time** | **String** | | [readonly]
**created_time** | **DateTime** | | [readonly]
**name** | Option<**String**> | | [optional]
**company** | **serde_json::Value** | |
**links** | Option<[**crate::models::Links**](Links.md)> | |
Expand Down
2 changes: 1 addition & 1 deletion docs/Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**client_id** | **String** | The unique ID of the client. | [readonly]
**created_time** | **String** | | [readonly]
**created_time** | **DateTime** | | [readonly]
**name** | Option<**String**> | The name of the client | [optional]
**options** | Option<[**crate::models::ClientOptions**](Client_options.md)> | | [optional]
**verification_keys** | Option<Vec<**[crate::models::ClientAccessKey](ClientAccessKey.md)**>> | A list of the service client access keys. | [optional][readonly]
Expand Down
2 changes: 1 addition & 1 deletion docs/Connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Name | Type | Description | Notes
**client_secret** | Option<**String**> | | [optional]
**data** | Option<[**crate::models::ConnectionData**](Connection_data.md)> | | [optional]
**default_connection_properties** | Option<[**crate::models::ConnectionDefaultConnectionProperties**](ConnectionDefaultConnectionProperties.md)> | | [optional]
**created_time** | Option<**String**> | | [optional][readonly]
**created_time** | Option<**DateTime**> | | [optional][readonly]
**tags** | Option<**::std::collections::HashMap<String, String>**> | The tags associated with this resource, this property is an map. { key1: value1, key2: value2 } | [optional]

[[API Models]](./README.md#documentation-for-models)[[API Endpoints]](./README.md#documentation-for-api-endpoints)[[Back to Repo]](../README.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/Extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**extension_id** | **String** | | [readonly]
**name** | Option<**String**> | The name of the extension. This name is visible in the Authress management portal | [optional]
**created_time** | **String** | | [readonly]
**created_time** | **DateTime** | | [readonly]
**application** | Option<[**crate::models::ExtensionApplication**](ExtensionApplication.md)> | | [optional]
**client** | [**crate::models::ExtensionClient**](ExtensionClient.md) | |
**tags** | Option<**::std::collections::HashMap<String, String>**> | The tags associated with this resource, this property is an map. { key1: value1, key2: value2 } | [optional]
Expand Down
2 changes: 1 addition & 1 deletion docs/Group.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**group_id** | Option<**String**> | Unique identifier for the groupId, can be specified on record creation. | [optional]
**name** | **String** | A helpful name for this record |
**last_updated** | Option<**String**> | The expected last time the group was updated | [optional][readonly]
**last_updated** | Option<**DateTime**> | The expected last time the group was updated | [optional][readonly]
**users** | Vec<**[crate::models::User](User.md)**> | The list of users in this group |
**admins** | Vec<**[crate::models::User](User.md)**> | The list of admins that can edit this record even if they do not have global record edit permissions. |
**links** | Option<[**crate::models::Links**](Links.md)> | |
Expand Down
3 changes: 2 additions & 1 deletion docs/GroupsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Name | Type | Description | Required | Notes

## update_group

> crate::models::Group update_group(group_id, group)
> crate::models::Group update_group(group_id, group, { expected_last_modified_time })
Update a group

Updates a group adding or removing user. Change a group updates the permissions and roles the users have access to. (Groups have a maximum size of ~100KB)
Expand All @@ -112,6 +112,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**group_id** | **String** | The identifier of the group. | [required] |
**group** | [**Group**](Group.md) | | [required] |
**expected_last_modified_time** | Option<**DateTime**> | The expected last time the group was modified. | |

### Return type

Expand Down
2 changes: 1 addition & 1 deletion docs/Tenant.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name | Type | Description | Notes
**tenant_lookup_identifier** | Option<**String**> | | [optional]
**data** | Option<[**crate::models::TenantData**](Tenant_data.md)> | | [optional]
**connection** | Option<[**crate::models::TenantConnection**](Tenant_connection.md)> | | [optional]
**created_time** | Option<**String**> | | [optional][readonly]
**created_time** | Option<**DateTime**> | | [optional][readonly]

[[API Models]](./README.md#documentation-for-models)[[API Endpoints]](./README.md#documentation-for-api-endpoints)[[Back to Repo]](../README.md)

Expand Down
11 changes: 4 additions & 7 deletions src/apis/access_records_api.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

use chrono::{DateTime, Utc};
use reqwest;

use crate::{apis::ResponseContent, AuthressSettings};
Expand Down Expand Up @@ -37,7 +38,7 @@ pub struct RespondToInviteParams {
#[derive(Default, Clone, Debug)]
pub struct UpdateRecordParams {
/// The expected last time the record was modified.
pub expected_last_modified_time: Option<String>
pub expected_last_modified_time: Option<DateTime<Utc>>
}


Expand Down Expand Up @@ -531,17 +532,13 @@ impl AccessRecordApi {
pub async fn update_record(&self, record_id: String, access_record: crate::models::AccessRecord, params: UpdateRecordParams) -> Result<(), Error<UpdateRecordError>> {
let local_var_configuration = &self.configuration;

// unbox the parameters
let expected_last_modified_time = params.expected_last_modified_time;


let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/v1/records/{recordId}", "", recordId=crate::apis::urlencode(record_id));
let mut local_var_req_builder = local_var_configuration.get_request_builder(reqwest::Method::PUT, local_var_uri_str);

if let Some(local_var_param_value) = expected_last_modified_time {
local_var_req_builder = local_var_req_builder.header("If-Unmodified-Since", local_var_param_value.to_string());
if let Some(local_var_param_value) = params.expected_last_modified_time {
local_var_req_builder = local_var_req_builder.header("If-Unmodified-Since", local_var_param_value.to_rfc3339_opts(chrono::SecondsFormat::Millis, true));
}
local_var_req_builder = local_var_req_builder.json(&access_record);

Expand Down
14 changes: 13 additions & 1 deletion src/apis/groups_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ pub struct GetGroupsParams {
pub filter: Option<String>
}

/// struct for passing parameters to the method [`update_group`]
#[derive(Default, Clone, Debug)]
pub struct UpdateGroupParams {
/// The expected last time the group was modified.
pub expected_last_modified_time: Option<chrono::DateTime<chrono::Utc>>
}

/// struct for typed errors of method [`create_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -178,13 +185,18 @@ impl GroupsApi {
}

/// Updates a group adding or removing user. Change a group updates the permissions and roles the users have access to. (Groups have a maximum size of ~100KB)
pub async fn update_group(&self, group_id: String, group: crate::models::Group) -> Result<crate::models::Group, Error<UpdateGroupError>> {
pub async fn update_group(&self, group_id: String, group: crate::models::Group, params: UpdateGroupParams) -> Result<crate::models::Group, Error<UpdateGroupError>> {
let local_var_configuration = &self.configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/v1/groups/{groupId}", "", groupId=crate::apis::urlencode(group_id));
let mut local_var_req_builder = local_var_configuration.get_request_builder(reqwest::Method::PUT, local_var_uri_str);

if let Some(local_var_param_value) = params.expected_last_modified_time {
local_var_req_builder = local_var_req_builder.header("If-Unmodified-Since", local_var_param_value.to_rfc3339_opts(chrono::SecondsFormat::Millis, true));
}

local_var_req_builder = local_var_req_builder.json(&group);

let local_var_req = local_var_req_builder.build()?;
Expand Down
2 changes: 1 addition & 1 deletion src/models/access_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct AccessRecord {
pub capacity: Option<f32>,
/// The expected last time the record was updated
#[serde(rename = "lastUpdated", skip_serializing_if = "Option::is_none")]
pub last_updated: Option<String>,
pub last_updated: Option<chrono::DateTime<chrono::Utc>>,
/// Current status of the access record.
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<Status>,
Expand Down
2 changes: 1 addition & 1 deletion src/models/access_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct AccessRequest {
pub request_id: String,
/// The expected last time the request was updated
#[serde(rename = "lastUpdated", skip_serializing_if = "Option::is_none")]
pub last_updated: Option<String>,
pub last_updated: Option<chrono::DateTime<chrono::Utc>>,
/// Current status of the access request.
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<Status>,
Expand Down
Loading

0 comments on commit 737e4ce

Please sign in to comment.