diff --git a/.vscode/settings.json b/.vscode/settings.json index e43d547..b2d376d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.words": [ + "chrono", "permissioned", "reqwest", "urlencode" diff --git a/Cargo.lock b/Cargo.lock index 0dd59a7..698266d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,6 +36,7 @@ dependencies = [ name = "authress" version = "0.0.0" dependencies = [ + "chrono", "reqwest", "serde", "serde_derive", @@ -110,15 +111,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", "serde", - "winapi", + "wasm-bindgen", + "windows-targets", ] [[package]] @@ -172,6 +175,16 @@ dependencies = [ "syn", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + [[package]] name = "encoding_rs" version = "0.8.32" @@ -661,20 +674,26 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.31" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -786,18 +805,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.171" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", @@ -882,9 +901,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.26" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -907,11 +926,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.23" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" dependencies = [ + "deranged", "itoa", + "powerfmt", "serde", "time-core", "time-macros", @@ -919,15 +940,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" dependencies = [ "time-core", ] diff --git a/Cargo.toml b/Cargo.toml index 34454cd..e780e17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } diff --git a/README.md b/README.md index 9b8a28f..1718ddf 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,14 @@ +

+ Authress Media Banner +

+ # Authress SDK for Rust

- - - - - - - - - + + + +

diff --git a/contributing.md b/contributing.md index 9b5371b..2a65355 100644 --- a/contributing.md +++ b/contributing.md @@ -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 \ No newline at end of file +* [x] If-unmodified-since should called `expectedLastModifiedTime`, accept string or dateTime and convert this to an ISO String \ No newline at end of file diff --git a/docs/AccessRecord.md b/docs/AccessRecord.md index 32b2578..54ba4fd 100644 --- a/docs/AccessRecord.md +++ b/docs/AccessRecord.md @@ -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> | The list of users this record applies to | [optional] **admins** | Option> | The list of admin that can edit this record even if they do not have global record edit permissions. | [optional] diff --git a/docs/AccessRecordsApi.md b/docs/AccessRecordsApi.md index 70ade2b..1d0384a 100644 --- a/docs/AccessRecordsApi.md +++ b/docs/AccessRecordsApi.md @@ -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) @@ -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 diff --git a/docs/AccessRequest.md b/docs/AccessRequest.md index b62c75c..1832d31 100644 --- a/docs/AccessRequest.md +++ b/docs/AccessRequest.md @@ -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)> | | diff --git a/docs/Account.md b/docs/Account.md index 9598a98..2f2609d 100644 --- a/docs/Account.md +++ b/docs/Account.md @@ -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)> | | diff --git a/docs/Client.md b/docs/Client.md index b77d416..b452ed5 100644 --- a/docs/Client.md +++ b/docs/Client.md @@ -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> | A list of the service client access keys. | [optional][readonly] diff --git a/docs/Connection.md b/docs/Connection.md index ea55eda..2cd2643 100644 --- a/docs/Connection.md +++ b/docs/Connection.md @@ -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**> | 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) diff --git a/docs/Extension.md b/docs/Extension.md index 39fd8aa..3a08874 100644 --- a/docs/Extension.md +++ b/docs/Extension.md @@ -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**> | The tags associated with this resource, this property is an map. { key1: value1, key2: value2 } | [optional] diff --git a/docs/Group.md b/docs/Group.md index 6b5fce4..2ca8260 100644 --- a/docs/Group.md +++ b/docs/Group.md @@ -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)> | | diff --git a/docs/GroupsApi.md b/docs/GroupsApi.md index d119e9b..fd7e6c8 100644 --- a/docs/GroupsApi.md +++ b/docs/GroupsApi.md @@ -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) @@ -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 diff --git a/docs/Tenant.md b/docs/Tenant.md index d191836..9b81b38 100644 --- a/docs/Tenant.md +++ b/docs/Tenant.md @@ -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) diff --git a/src/apis/access_records_api.rs b/src/apis/access_records_api.rs index 5f6cb14..c6d1675 100644 --- a/src/apis/access_records_api.rs +++ b/src/apis/access_records_api.rs @@ -1,4 +1,5 @@ +use chrono::{DateTime, Utc}; use reqwest; use crate::{apis::ResponseContent, AuthressSettings}; @@ -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 + pub expected_last_modified_time: Option> } @@ -531,17 +532,13 @@ impl AccessRecordApi { pub async fn update_record(&self, record_id: String, access_record: crate::models::AccessRecord, params: UpdateRecordParams) -> Result<(), Error> { 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); diff --git a/src/apis/groups_api.rs b/src/apis/groups_api.rs index b6c0700..515cd7b 100644 --- a/src/apis/groups_api.rs +++ b/src/apis/groups_api.rs @@ -15,6 +15,13 @@ pub struct GetGroupsParams { pub filter: Option } +/// 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> +} + /// struct for typed errors of method [`create_group`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -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> { + pub async fn update_group(&self, group_id: String, group: crate::models::Group, params: UpdateGroupParams) -> Result> { 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()?; diff --git a/src/models/access_record.rs b/src/models/access_record.rs index a096195..9c817da 100644 --- a/src/models/access_record.rs +++ b/src/models/access_record.rs @@ -18,7 +18,7 @@ pub struct AccessRecord { pub capacity: Option, /// The expected last time the record was updated #[serde(rename = "lastUpdated", skip_serializing_if = "Option::is_none")] - pub last_updated: Option, + pub last_updated: Option>, /// Current status of the access record. #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/src/models/access_request.rs b/src/models/access_request.rs index b2b8656..c9a3e72 100644 --- a/src/models/access_request.rs +++ b/src/models/access_request.rs @@ -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, + pub last_updated: Option>, /// Current status of the access request. #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/src/models/account.rs b/src/models/account.rs index e3266f1..7bd7929 100644 --- a/src/models/account.rs +++ b/src/models/account.rs @@ -6,7 +6,7 @@ pub struct Account { #[serde(rename = "accountId")] pub account_id: String, #[serde(rename = "createdTime")] - pub created_time: String, + pub created_time: Option>, #[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] pub name: Option>, #[serde(rename = "links", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] @@ -14,10 +14,10 @@ pub struct Account { } impl Account { - pub fn new(account_id: String, created_time: String) -> Account { + pub fn new(account_id: String) -> Account { Account { account_id, - created_time, + created_time: None, name: None, links: None, } diff --git a/src/models/client.rs b/src/models/client.rs index 9614f48..a6b3f6d 100644 --- a/src/models/client.rs +++ b/src/models/client.rs @@ -8,7 +8,7 @@ pub struct Client { #[serde(rename = "clientId")] pub client_id: String, #[serde(rename = "createdTime")] - pub created_time: String, + pub created_time: Option>, /// The name of the client #[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] pub name: Option>, @@ -24,10 +24,10 @@ pub struct Client { impl Client { /// A client configuration. - pub fn new(client_id: String, created_time: String) -> Client { + pub fn new(client_id: String) -> Client { Client { client_id, - created_time, + created_time: None, name: None, options: None, verification_keys: None, diff --git a/src/models/connection.rs b/src/models/connection.rs index 3ab51d8..ffd6d20 100644 --- a/src/models/connection.rs +++ b/src/models/connection.rs @@ -24,7 +24,7 @@ pub struct Connection { #[serde(rename = "defaultConnectionProperties", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] pub default_connection_properties: Option>, #[serde(rename = "createdTime", skip_serializing_if = "Option::is_none")] - pub created_time: Option, + pub created_time: Option>, /// The tags associated with this resource, this property is an map. { key1: value1, key2: value2 } #[serde(rename = "tags", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] pub tags: Option>>, diff --git a/src/models/extension.rs b/src/models/extension.rs index 0006d5d..c03f5ed 100644 --- a/src/models/extension.rs +++ b/src/models/extension.rs @@ -9,7 +9,7 @@ pub struct Extension { #[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] pub name: Option>, #[serde(rename = "createdTime")] - pub created_time: String, + pub created_time: Option>, #[serde(rename = "application", skip_serializing_if = "Option::is_none")] pub application: Option>, #[serde(rename = "client")] @@ -20,11 +20,11 @@ pub struct Extension { } impl Extension { - pub fn new(extension_id: String, created_time: String, client: crate::models::ExtensionClient) -> Extension { + pub fn new(extension_id: String, client: crate::models::ExtensionClient) -> Extension { Extension { extension_id, name: None, - created_time, + created_time: None, application: None, client: Box::new(client), tags: None, diff --git a/src/models/group.rs b/src/models/group.rs index 3298794..5197872 100644 --- a/src/models/group.rs +++ b/src/models/group.rs @@ -12,7 +12,7 @@ pub struct Group { pub name: String, /// The expected last time the group was updated #[serde(rename = "lastUpdated", skip_serializing_if = "Option::is_none")] - pub last_updated: Option, + pub last_updated: Option>, /// The list of users in this group #[serde(rename = "users")] pub users: Vec, diff --git a/src/models/tenant.rs b/src/models/tenant.rs index 5b2a1fc..f3b81f1 100644 --- a/src/models/tenant.rs +++ b/src/models/tenant.rs @@ -12,7 +12,7 @@ pub struct Tenant { #[serde(rename = "connection", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] pub connection: Option>>, #[serde(rename = "createdTime", skip_serializing_if = "Option::is_none")] - pub created_time: Option, + pub created_time: Option>, } impl Tenant {