From fd93366a00f519832cd668f35281b83884226720 Mon Sep 17 00:00:00 2001 From: VRCCat Date: Mon, 15 Apr 2024 22:18:47 +0000 Subject: [PATCH] Upgrade Rust SDK to spec 1.17.0 --- .openapi-generator/FILES | 2 ++ Cargo.toml | 2 +- docs/GroupAccessType.md | 10 ++++++++ docs/Instance.md | 9 ++++++-- docs/InstancesApi.md | 33 ++++++++++++++++++++++++++ src/apis/friends_api.rs | 1 + src/apis/groups_api.rs | 4 +++- src/apis/instances_api.rs | 41 +++++++++++++++++++++++++++++++++ src/models/group_access_type.rs | 41 +++++++++++++++++++++++++++++++++ src/models/instance.rs | 33 ++++++++++++++++++-------- src/models/mod.rs | 2 ++ 11 files changed, 165 insertions(+), 13 deletions(-) create mode 100644 docs/GroupAccessType.md create mode 100644 src/models/group_access_type.rs diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index bc8e8d6..5d07bde 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -45,6 +45,7 @@ docs/FinishFileDataUploadRequest.md docs/FriendStatus.md docs/FriendsApi.md docs/Group.md +docs/GroupAccessType.md docs/GroupAnnouncement.md docs/GroupAuditLogEntry.md docs/GroupGallery.md @@ -199,6 +200,7 @@ src/models/file_version_upload_status.rs src/models/finish_file_data_upload_request.rs src/models/friend_status.rs src/models/group.rs +src/models/group_access_type.rs src/models/group_announcement.rs src/models/group_audit_log_entry.rs src/models/group_gallery.rs diff --git a/Cargo.toml b/Cargo.toml index a4be008..0ac2583 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vrchatapi" -version = "1.16.8" +version = "1.17.0" authors = ["vrchatapi.lpv0t@aries.fyi"] description = "VRChat API Client for Rust" license = "MIT" diff --git a/docs/GroupAccessType.md b/docs/GroupAccessType.md new file mode 100644 index 0000000..fba5de8 --- /dev/null +++ b/docs/GroupAccessType.md @@ -0,0 +1,10 @@ +# GroupAccessType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Instance.md b/docs/Instance.md index dbdb89e..7e432cd 100644 --- a/docs/Instance.md +++ b/docs/Instance.md @@ -14,7 +14,7 @@ Name | Type | Description | Notes **location** | **String** | InstanceID can be \"offline\" on User profiles if you are not friends with that user and \"private\" if you are friends and user is in private instance. | **n_users** | **i32** | | **name** | **String** | | -**owner_id** | Option<**String**> | A users unique ID, usually in the form of `usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469`. Legacy players can have old IDs in the form of `8JoV9XEdpo`. The ID can never be changed. | [optional] +**owner_id** | Option<**String**> | A groupId if the instance type is \"group\", null if instance type is public, or a userId otherwise | [optional] **permanent** | **bool** | | [default to false] **photon_region** | [**crate::models::Region**](Region.md) | | **platforms** | [**crate::models::InstancePlatforms**](InstancePlatforms.md) | | @@ -30,11 +30,16 @@ Name | Type | Description | Notes **queue_enabled** | **bool** | | **queue_size** | **i32** | | **recommended_capacity** | **i32** | | -**role_restricted** | **bool** | | +**role_restricted** | Option<**bool**> | | [optional] **strict** | **bool** | | **user_count** | **i32** | | **world** | [**crate::models::World**](World.md) | | **users** | Option<[**Vec**](LimitedUser.md)> | The users field is present on instances created by the requesting user. | [optional] +**group_access_type** | Option<[**crate::models::GroupAccessType**](GroupAccessType.md)> | | [optional] +**has_capacity_for_you** | Option<**bool**> | | [optional] +**nonce** | Option<**String**> | | [optional] +**closed_at** | Option<**String**> | | [optional] +**hard_close** | Option<**bool**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/InstancesApi.md b/docs/InstancesApi.md index f6bbe5f..a27ec0d 100644 --- a/docs/InstancesApi.md +++ b/docs/InstancesApi.md @@ -4,6 +4,7 @@ All URIs are relative to *https://api.vrchat.cloud/api/1* Method | HTTP request | Description ------------- | ------------- | ------------- +[**close_instance**](InstancesApi.md#close_instance) | **DELETE** /instances/{worldId}:{instanceId} | Close Instance [**get_instance**](InstancesApi.md#get_instance) | **GET** /instances/{worldId}:{instanceId} | Get Instance [**get_instance_by_short_name**](InstancesApi.md#get_instance_by_short_name) | **GET** /instances/s/{shortName} | Get Instance By Short Name [**get_short_name**](InstancesApi.md#get_short_name) | **GET** /instances/{worldId}:{instanceId}/shortName | Get Instance Short Name @@ -11,6 +12,38 @@ Method | HTTP request | Description +## close_instance + +> crate::models::Instance close_instance(world_id, instance_id, hard_close) +Close Instance + +Close an instance. You can only close an instance if the ownerId is yourself or if the instance owner is a group and you have the `group-instance-moderate` permission. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**world_id** | **String** | Must be a valid world ID. | [required] | +**instance_id** | **String** | Must be a valid instance ID. | [required] | +**hard_close** | Option<**bool**> | Whether to hard close the instance. Defaults to false. | | + +### Return type + +[**crate::models::Instance**](Instance.md) + +### Authorization + +[authCookie](../README.md#authCookie) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## get_instance > crate::models::Instance get_instance(world_id, instance_id) diff --git a/src/apis/friends_api.rs b/src/apis/friends_api.rs index ad8265c..e8b80bd 100644 --- a/src/apis/friends_api.rs +++ b/src/apis/friends_api.rs @@ -26,6 +26,7 @@ pub enum DeleteFriendRequestError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FriendError { + Status400(crate::models::Error), Status401(crate::models::Error), Status404(crate::models::Error), UnknownValue(serde_json::Value), diff --git a/src/apis/groups_api.rs b/src/apis/groups_api.rs index e5873e7..41adab4 100644 --- a/src/apis/groups_api.rs +++ b/src/apis/groups_api.rs @@ -80,8 +80,9 @@ pub enum CreateGroupGalleryError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateGroupInviteError { - Status400(), + Status400(crate::models::Error), Status401(crate::models::Error), + Status403(crate::models::Error), Status404(crate::models::Error), UnknownValue(serde_json::Value), } @@ -237,6 +238,7 @@ pub enum GetGroupPermissionsError { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetGroupRequestsError { + Status400(crate::models::Error), Status403(crate::models::Error), Status404(crate::models::Error), UnknownValue(serde_json::Value), diff --git a/src/apis/instances_api.rs b/src/apis/instances_api.rs index de5c3cb..9af5f3a 100644 --- a/src/apis/instances_api.rs +++ b/src/apis/instances_api.rs @@ -13,6 +13,16 @@ use crate::apis::ResponseContent; use super::{Error, configuration}; +/// struct for typed errors of method [`close_instance`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CloseInstanceError { + Status401(crate::models::Error), + Status403(crate::models::Error), + Status404(crate::models::Error), + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`get_instance`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -47,6 +57,37 @@ pub enum SendSelfInviteError { } +/// Close an instance. You can only close an instance if the ownerId is yourself or if the instance owner is a group and you have the `group-instance-moderate` permission. +pub fn close_instance(configuration: &configuration::Configuration, world_id: &str, instance_id: &str, hard_close: Option) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/instances/{worldId}:{instanceId}", local_var_configuration.base_path, worldId=crate::apis::urlencode(world_id), instanceId=crate::apis::urlencode(instance_id)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = hard_close { + local_var_req_builder = local_var_req_builder.query(&[("hardClose", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + /// Returns an instance. Please read [Instances Tutorial](https://vrchatapi.github.io/tutorials/instances/) for more information on Instances. If an invalid instanceId is provided, this endpoint will simply return \"null\"! pub fn get_instance(configuration: &configuration::Configuration, world_id: &str, instance_id: &str) -> Result> { let local_var_configuration = configuration; diff --git a/src/models/group_access_type.rs b/src/models/group_access_type.rs new file mode 100644 index 0000000..3343f97 --- /dev/null +++ b/src/models/group_access_type.rs @@ -0,0 +1,41 @@ +/* + * VRChat API Documentation + * + * + * Contact: vrchatapi.lpv0t@aries.fyi + * Generated by: https://openapi-generator.tech + */ + +/// GroupAccessType : Group access type when the instance type is \"group\" + +/// Group access type when the instance type is \"group\" +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum GroupAccessType { + #[serde(rename = "public")] + Public, + #[serde(rename = "plus")] + Plus, + #[serde(rename = "member")] + Member, + +} + +impl ToString for GroupAccessType { + fn to_string(&self) -> String { + match self { + Self::Public => String::from("public"), + Self::Plus => String::from("plus"), + Self::Member => String::from("member"), + } + } +} + +impl Default for GroupAccessType { + fn default() -> GroupAccessType { + Self::Public + } +} + + + + diff --git a/src/models/instance.rs b/src/models/instance.rs index 017650c..c1c1a33 100644 --- a/src/models/instance.rs +++ b/src/models/instance.rs @@ -35,9 +35,9 @@ pub struct Instance { pub n_users: i32, #[serde(rename = "name")] pub name: String, - /// A users unique ID, usually in the form of `usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469`. Legacy players can have old IDs in the form of `8JoV9XEdpo`. The ID can never be changed. - #[serde(rename = "ownerId", skip_serializing_if = "Option::is_none")] - pub owner_id: Option, + /// A groupId if the instance type is \"group\", null if instance type is public, or a userId otherwise + #[serde(rename = "ownerId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub owner_id: Option>, #[serde(rename = "permanent")] pub permanent: bool, #[serde(rename = "photonRegion")] @@ -48,8 +48,8 @@ pub struct Instance { pub region: crate::models::Region, #[serde(rename = "secureName")] pub secure_name: String, - #[serde(rename = "shortName", skip_serializing_if = "Option::is_none")] - pub short_name: Option, + #[serde(rename = "shortName", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub short_name: Option>, /// The tags array on Instances usually contain the language tags of the people in the instance. #[serde(rename = "tags")] pub tags: Vec, @@ -73,8 +73,8 @@ pub struct Instance { pub queue_size: i32, #[serde(rename = "recommendedCapacity")] pub recommended_capacity: i32, - #[serde(rename = "roleRestricted")] - pub role_restricted: bool, + #[serde(rename = "roleRestricted", skip_serializing_if = "Option::is_none")] + pub role_restricted: Option, #[serde(rename = "strict")] pub strict: bool, #[serde(rename = "userCount")] @@ -84,11 +84,21 @@ pub struct Instance { /// The users field is present on instances created by the requesting user. #[serde(rename = "users", skip_serializing_if = "Option::is_none")] pub users: Option>, + #[serde(rename = "groupAccessType", skip_serializing_if = "Option::is_none")] + pub group_access_type: Option, + #[serde(rename = "hasCapacityForYou", skip_serializing_if = "Option::is_none")] + pub has_capacity_for_you: Option, + #[serde(rename = "nonce", skip_serializing_if = "Option::is_none")] + pub nonce: Option, + #[serde(rename = "closedAt", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub closed_at: Option>, + #[serde(rename = "hardClose", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub hard_close: Option>, } impl Instance { /// * `hidden` field is only present if InstanceType is `hidden` aka \"Friends+\", and is instance creator. * `friends` field is only present if InstanceType is `friends` aka \"Friends\", and is instance creator. * `private` field is only present if InstanceType is `private` aka \"Invite\" or \"Invite+\", and is instance creator. - pub fn new(active: bool, can_request_invite: bool, capacity: i32, client_number: String, full: bool, id: String, instance_id: String, location: String, n_users: i32, name: String, permanent: bool, photon_region: crate::models::Region, platforms: crate::models::InstancePlatforms, region: crate::models::Region, secure_name: String, tags: Vec, r#type: crate::models::InstanceType, world_id: String, queue_enabled: bool, queue_size: i32, recommended_capacity: i32, role_restricted: bool, strict: bool, user_count: i32, world: crate::models::World) -> Instance { + pub fn new(active: bool, can_request_invite: bool, capacity: i32, client_number: String, full: bool, id: String, instance_id: String, location: String, n_users: i32, name: String, permanent: bool, photon_region: crate::models::Region, platforms: crate::models::InstancePlatforms, region: crate::models::Region, secure_name: String, tags: Vec, r#type: crate::models::InstanceType, world_id: String, queue_enabled: bool, queue_size: i32, recommended_capacity: i32, strict: bool, user_count: i32, world: crate::models::World) -> Instance { Instance { active, can_request_invite, @@ -116,11 +126,16 @@ impl Instance { queue_enabled, queue_size, recommended_capacity, - role_restricted, + role_restricted: None, strict, user_count, world: Box::new(world), users: None, + group_access_type: None, + has_capacity_for_you: None, + nonce: None, + closed_at: None, + hard_close: None, } } } diff --git a/src/models/mod.rs b/src/models/mod.rs index abc651a..89dab0f 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -76,6 +76,8 @@ pub mod friend_status; pub use self::friend_status::FriendStatus; pub mod group; pub use self::group::Group; +pub mod group_access_type; +pub use self::group_access_type::GroupAccessType; pub mod group_announcement; pub use self::group_announcement::GroupAnnouncement; pub mod group_audit_log_entry;