From eb09d2ae56902f0cf33624d8c45f10d6f0eb23a2 Mon Sep 17 00:00:00 2001 From: RobWalt Date: Thu, 24 Aug 2023 18:31:37 +0200 Subject: [PATCH] feat: add more models from swagger docs --- src/types/api/activity.rs | 30 +++++----- src/types/api/activity_pub.rs | 6 ++ src/types/api/api_error.rs | 12 ++-- src/types/api/blocked_user.rs | 4 ++ src/types/api/change_file_operation.rs | 22 +++++++ src/types/api/change_file_options.rs | 26 +++++++++ .../api/creation/{file_options.rs => file.rs} | 0 src/types/api/creation/fork.rs | 11 ++++ .../creation/{comment.rs => issue_comment.rs} | 0 src/types/api/creation/mod.rs | 11 ++-- ...th_application.rs => oauth_application.rs} | 0 .../creation/{commit_status.rs => status.rs} | 0 src/types/api/creation/team.rs | 20 +++++++ src/types/api/creation/user.rs | 20 +++++++ src/types/api/cron.rs | 10 ++++ src/types/api/delete_email.rs | 10 ++++ src/types/api/delete_file.rs | 24 ++++++++ .../api/edit/{comment.rs => issue_comment.rs} | 0 src/types/api/edit/mod.rs | 4 +- src/types/api/edit/team.rs | 20 +++++++ src/types/api/edit/user.rs | 23 ++++++++ src/types/api/email.rs | 10 ++++ src/types/api/file_commit_response.rs | 25 ++++++++ src/types/api/file_delete_response.rs | 34 +++++++++++ src/types/api/file_response.rs | 58 +++++++++++++++++++ src/types/api/general_api_settings.rs | 9 +++ src/types/api/mod.rs | 12 ++++ 27 files changed, 375 insertions(+), 26 deletions(-) create mode 100644 src/types/api/activity_pub.rs create mode 100644 src/types/api/blocked_user.rs create mode 100644 src/types/api/change_file_operation.rs create mode 100644 src/types/api/change_file_options.rs rename src/types/api/creation/{file_options.rs => file.rs} (100%) create mode 100644 src/types/api/creation/fork.rs rename src/types/api/creation/{comment.rs => issue_comment.rs} (100%) rename src/types/api/creation/{oath_application.rs => oauth_application.rs} (100%) rename src/types/api/creation/{commit_status.rs => status.rs} (100%) create mode 100644 src/types/api/creation/team.rs create mode 100644 src/types/api/creation/user.rs create mode 100644 src/types/api/cron.rs create mode 100644 src/types/api/delete_email.rs create mode 100644 src/types/api/delete_file.rs rename src/types/api/edit/{comment.rs => issue_comment.rs} (100%) create mode 100644 src/types/api/edit/team.rs create mode 100644 src/types/api/edit/user.rs create mode 100644 src/types/api/email.rs create mode 100644 src/types/api/file_commit_response.rs create mode 100644 src/types/api/file_delete_response.rs create mode 100644 src/types/api/file_response.rs create mode 100644 src/types/api/general_api_settings.rs diff --git a/src/types/api/activity.rs b/src/types/api/activity.rs index 13a3630..aecb45e 100644 --- a/src/types/api/activity.rs +++ b/src/types/api/activity.rs @@ -1,15 +1,15 @@ -// Activity{ -// act_user User{...} -// act_user_id [...] -// comment Comment{...} -// comment_id [...] -// content [...] -// created [...] -// id [...] -// is_private [...] -// op_type [...] -// ref_name [...] -// repo Repository{...} -// repo_id [...] -// user_id [...] -// } +//Activity{ +//act_user User{...} +//act_user_id integer($int64) +//comment Comment{...} +//comment_id integer($int64) +//content string +//created string($date-time) +//id integer($int64) +//is_private boolean +//op_type string +//ref_name string +//repo Repository{...} +//repo_id integer($int64) +//user_id integer($int64) +//} diff --git a/src/types/api/activity_pub.rs b/src/types/api/activity_pub.rs new file mode 100644 index 0000000..d74a1e9 --- /dev/null +++ b/src/types/api/activity_pub.rs @@ -0,0 +1,6 @@ +//ActivityPub{ +//description: +//ActivityPub type +// +//@context string +//} diff --git a/src/types/api/api_error.rs b/src/types/api/api_error.rs index 0fcc4f7..20eb649 100644 --- a/src/types/api/api_error.rs +++ b/src/types/api/api_error.rs @@ -1,7 +1,7 @@ -// APIError{ -// description: -// APIError is an api error with a message +//APIError{ +//description: +//APIError is an api error with a message // -// message [...] -// url [...] -// } +//message string +//url string +//} diff --git a/src/types/api/blocked_user.rs b/src/types/api/blocked_user.rs new file mode 100644 index 0000000..bc418eb --- /dev/null +++ b/src/types/api/blocked_user.rs @@ -0,0 +1,4 @@ +//BlockedUser represents a blocked user.{ +//block_id integer($int64) +//created_at string($date-time) +//} diff --git a/src/types/api/change_file_operation.rs b/src/types/api/change_file_operation.rs new file mode 100644 index 0000000..f658cc0 --- /dev/null +++ b/src/types/api/change_file_operation.rs @@ -0,0 +1,22 @@ +//ChangeFileOperation{ +//description: +//ChangeFileOperation for creating, updating or deleting a file +// +//content string +//new or updated file content, must be base64 encoded +// +//from_path string +//old path of the file to move +// +//operation* string +//indicates what to do with the file +// +//Enum: +//Array [ 3 ] +//path* string +//path to the existing or new file +// +//sha string +//sha is the SHA for the file that already exists, required for update or delete +// +//} diff --git a/src/types/api/change_file_options.rs b/src/types/api/change_file_options.rs new file mode 100644 index 0000000..3ca1225 --- /dev/null +++ b/src/types/api/change_file_options.rs @@ -0,0 +1,26 @@ +//ChangeFilesOptions{ +//description: +//ChangeFilesOptions options for creating, updating or deleting multiple files +//Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// +//author Identity{...} +//branch string +//branch (optional) to base this file from. if not given, the default branch is used +// +//committer Identity{...} +//dates CommitDateOptions{...} +//files* [ +//x-go-name: Files +//list of file operations +// +//ChangeFileOperation{...}] +//message string +//message (optional) for the commit of this file. if not supplied, a default message will be used +// +//new_branch string +//new_branch (optional) will make a new branch from branch before creating the file +// +//signoff boolean +//Add a Signed-off-by trailer by the committer at the end of the commit log message. +// +//} diff --git a/src/types/api/creation/file_options.rs b/src/types/api/creation/file.rs similarity index 100% rename from src/types/api/creation/file_options.rs rename to src/types/api/creation/file.rs diff --git a/src/types/api/creation/fork.rs b/src/types/api/creation/fork.rs new file mode 100644 index 0000000..bb6aec5 --- /dev/null +++ b/src/types/api/creation/fork.rs @@ -0,0 +1,11 @@ +//CreateForkOption{ +//description: +//CreateForkOption options for creating a fork +// +//name string +//name of the forked repository +// +//organization string +//organization name, if forking into an organization +// +//} diff --git a/src/types/api/creation/comment.rs b/src/types/api/creation/issue_comment.rs similarity index 100% rename from src/types/api/creation/comment.rs rename to src/types/api/creation/issue_comment.rs diff --git a/src/types/api/creation/mod.rs b/src/types/api/creation/mod.rs index 8407bda..b8020d3 100644 --- a/src/types/api/creation/mod.rs +++ b/src/types/api/creation/mod.rs @@ -5,16 +5,16 @@ pub mod organization; pub mod access_token; /* to-todo */ pub mod branch; /* to-todo */ pub mod branch_protection; -/* to-todo */ pub mod comment; -/* to-todo */ pub mod commit_status; /* to-todo */ pub mod email; -/* to-todo */ pub mod file_options; +/* to-todo */ pub mod file; +/* to-todo */ pub mod fork; /* to-todo */ pub mod gpg_key; /* to-todo */ pub mod hook; /* to-todo */ pub mod issue; +/* to-todo */ pub mod issue_comment; /* to-todo */ pub mod key; /* to-todo */ pub mod milestone; -/* to-todo */ pub mod oath_application; +/* to-todo */ pub mod oauth_application; /* to-todo */ pub mod pull_request; /* to-todo */ pub mod pull_review; /* to-todo */ pub mod pull_review_comment; @@ -22,6 +22,9 @@ pub mod access_token; /* to-todo */ pub mod release; /* to-todo */ pub mod repository; /* to-todo */ pub mod request_review; +/* to-todo */ pub mod status; /* to-todo */ pub mod tag; +/* to-todo */ pub mod team; /* to-todo */ pub mod template_repository; +/* to-todo */ pub mod user; /* to-todo */ pub mod wiki_page; diff --git a/src/types/api/creation/oath_application.rs b/src/types/api/creation/oauth_application.rs similarity index 100% rename from src/types/api/creation/oath_application.rs rename to src/types/api/creation/oauth_application.rs diff --git a/src/types/api/creation/commit_status.rs b/src/types/api/creation/status.rs similarity index 100% rename from src/types/api/creation/commit_status.rs rename to src/types/api/creation/status.rs diff --git a/src/types/api/creation/team.rs b/src/types/api/creation/team.rs new file mode 100644 index 0000000..a99e092 --- /dev/null +++ b/src/types/api/creation/team.rs @@ -0,0 +1,20 @@ +//CreateTeamOption{ +//description: +//CreateTeamOption options for creating a team +// +//can_create_org_repo boolean +//description string +//includes_all_repositories boolean +//name* string +//permission string +//Enum: +//Array [ 3 ] +//units [ +//x-go-name: Units +//example: List [ "repo.code", "repo.issues", "repo.ext_issues", "repo.wiki", "repo.pulls", "repo.releases", "repo.projects", "repo.ext_wiki" ] +//string] +//units_map { +//< * >: string +//} +//example: OrderedMap { "repo.code": "read", "repo.ext_issues": "none", "repo.ext_wiki": "none", "repo.issues": "write", "repo.projects": "none", "repo.pulls": "owner", "repo.releases": "none", "repo.wiki": "admin" } +//} diff --git a/src/types/api/creation/user.rs b/src/types/api/creation/user.rs new file mode 100644 index 0000000..e4db1c5 --- /dev/null +++ b/src/types/api/creation/user.rs @@ -0,0 +1,20 @@ +//CreateUserOption{ +//description: +//CreateUserOption create user options +// +//created_at string($date-time) +//For explicitly setting the user creation timestamp. Useful when users are +//migrated from other systems. When omitted, the user's creation timestamp +//will be set to "now". +// +//email* string($email) +//full_name string +//login_name string +//must_change_password boolean +//password* string +//restricted boolean +//send_notify boolean +//source_id integer($int64) +//username* string +//visibility string +//} diff --git a/src/types/api/cron.rs b/src/types/api/cron.rs new file mode 100644 index 0000000..33d2c4c --- /dev/null +++ b/src/types/api/cron.rs @@ -0,0 +1,10 @@ +//Cron{ +//description: +//Cron represents a Cron task +// +//exec_times integer($int64) +//name string +//next string($date-time) +//prev string($date-time) +//schedule string +//} diff --git a/src/types/api/delete_email.rs b/src/types/api/delete_email.rs new file mode 100644 index 0000000..e360a88 --- /dev/null +++ b/src/types/api/delete_email.rs @@ -0,0 +1,10 @@ +//DeleteEmailOption{ +//description: +//DeleteEmailOption options when deleting email addresses +// +//emails [ +//x-go-name: Emails +//email addresses to delete +// +//string] +//} diff --git a/src/types/api/delete_file.rs b/src/types/api/delete_file.rs new file mode 100644 index 0000000..b45a05f --- /dev/null +++ b/src/types/api/delete_file.rs @@ -0,0 +1,24 @@ +//DeleteFileOptions{ +//description: +//DeleteFileOptions options for deleting files (used for other File structs below) +//Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// +//author Identity{...} +//branch string +//branch (optional) to base this file from. if not given, the default branch is used +// +//committer Identity{...} +//dates CommitDateOptions{...} +//message string +//message (optional) for the commit of this file. if not supplied, a default message will be used +// +//new_branch string +//new_branch (optional) will make a new branch from branch before creating the file +// +//sha* string +//sha is the SHA for the file that already exists +// +//signoff boolean +//Add a Signed-off-by trailer by the committer at the end of the commit log message. +// +//} diff --git a/src/types/api/edit/comment.rs b/src/types/api/edit/issue_comment.rs similarity index 100% rename from src/types/api/edit/comment.rs rename to src/types/api/edit/issue_comment.rs diff --git a/src/types/api/edit/mod.rs b/src/types/api/edit/mod.rs index 00f3853..c4e00eb 100644 --- a/src/types/api/edit/mod.rs +++ b/src/types/api/edit/mod.rs @@ -5,14 +5,16 @@ pub mod organization; /* to-todo */ pub mod attachment; /* to-todo */ pub mod branch_protection; -/* to-todo */ pub mod comment; /* to-todo */ pub mod deadline; /* to-todo */ pub mod file_options; /* to-todo */ pub mod git_hook; /* to-todo */ pub mod issue; +/* to-todo */ pub mod issue_comment; /* to-todo */ pub mod milestone; /* to-todo */ pub mod pull_request; /* to-todo */ pub mod reaction; /* to-todo */ pub mod release; /* to-todo */ pub mod repository; +/* to-todo */ pub mod team; +/* to-todo */ pub mod user; /* to-todo */ pub mod user_setting; diff --git a/src/types/api/edit/team.rs b/src/types/api/edit/team.rs new file mode 100644 index 0000000..cc305a6 --- /dev/null +++ b/src/types/api/edit/team.rs @@ -0,0 +1,20 @@ +//EditTeamOption{ +//description: +//EditTeamOption options for editing a team +// +//can_create_org_repo boolean +//description string +//includes_all_repositories boolean +//name* string +//permission string +//Enum: +//[ read, write, admin ] +//units [ +//x-go-name: Units +//example: List [ "repo.code", "repo.issues", "repo.ext_issues", "repo.wiki", "repo.pulls", "repo.releases", "repo.projects", "repo.ext_wiki" ] +//string] +//units_map { +//< * >: string +//} +//example: OrderedMap { "repo.code": "read", "repo.ext_issues": "none", "repo.ext_wiki": "none", "repo.issues": "write", "repo.projects": "none", "repo.pulls": "owner", "repo.releases": "none", "repo.wiki": "admin" } +//} diff --git a/src/types/api/edit/user.rs b/src/types/api/edit/user.rs new file mode 100644 index 0000000..bf6da71 --- /dev/null +++ b/src/types/api/edit/user.rs @@ -0,0 +1,23 @@ +//EditUserOption{ +//description: +//EditUserOption edit user options +// +//active boolean +//admin boolean +//allow_create_organization boolean +//allow_git_hook boolean +//allow_import_local boolean +//description string +//email string($email) +//full_name string +//location string +//login_name* string +//max_repo_creation integer($int64) +//must_change_password boolean +//password string +//prohibit_login boolean +//restricted boolean +//source_id* integer($int64) +//visibility string +//website string +//} diff --git a/src/types/api/email.rs b/src/types/api/email.rs new file mode 100644 index 0000000..0fcb4ad --- /dev/null +++ b/src/types/api/email.rs @@ -0,0 +1,10 @@ +//Email{ +//description: +//Email an email address belonging to a user +// +//email string($email) +//primary boolean +//user_id integer($int64) +//username string +//verified boolean +//} diff --git a/src/types/api/file_commit_response.rs b/src/types/api/file_commit_response.rs new file mode 100644 index 0000000..57445cc --- /dev/null +++ b/src/types/api/file_commit_response.rs @@ -0,0 +1,25 @@ +//FileCommitResponse contains information generated from a Git commit for a repo's file.{ +//author CommitUser contains information of a user in the context of a commit.{ +//date string +//email string($email) +//name string +//} +//committer CommitUser contains information of a user in the context of a commit.{ +//date string +//email string($email) +//name string +//} +//created string($date-time) +//html_url string +//message string +//parents [ +//x-go-name: Parents +//CommitMeta contains meta information of a commit in terms of API.{...}] +//sha string +//tree CommitMeta contains meta information of a commit in terms of API.{ +//created string($date-time) +//sha string +//url string +//} +//url string +//} diff --git a/src/types/api/file_delete_response.rs b/src/types/api/file_delete_response.rs new file mode 100644 index 0000000..4434d82 --- /dev/null +++ b/src/types/api/file_delete_response.rs @@ -0,0 +1,34 @@ +//FileDeleteResponse{ +//description: +//FileDeleteResponse contains information about a repo's file that was deleted +// +//commit FileCommitResponse contains information generated from a Git commit for a repo's file.{ +//author CommitUser contains information of a user in the context of a commit.{ +//date string +//email string($email) +//name string +//} +//committer CommitUser contains information of a user in the context of a commit.{...} +//created string($date-time) +//html_url string +//message string +//parents [ +//x-go-name: Parents +//CommitMeta contains meta information of a commit in terms of API.{...}] +//sha string +//tree CommitMeta contains meta information of a commit in terms of API.{...} +//url string +//} +//content { +//} +//verification PayloadCommitVerification{ +//description: +//PayloadCommitVerification represents the GPG verification of a commit +// +//payload string +//reason string +//signature string +//signer PayloadUser{...} +//verified boolean +//} +//} diff --git a/src/types/api/file_response.rs b/src/types/api/file_response.rs new file mode 100644 index 0000000..0f6314e --- /dev/null +++ b/src/types/api/file_response.rs @@ -0,0 +1,58 @@ +//FileResponse{ +//description: +//FileResponse contains information about a repo's file +// +//commit FileCommitResponse contains information generated from a Git commit for a repo's file.{ +//author CommitUser contains information of a user in the context of a commit.{...} +//committer CommitUser contains information of a user in the context of a commit.{...} +//created string($date-time) +//html_url string +//message string +//parents [ +//x-go-name: Parents +//CommitMeta contains meta information of a commit in terms of API.{...}] +//sha string +//tree CommitMeta contains meta information of a commit in terms of API.{...} +//url string +//} +//content ContentsResponse{ +//description: +//ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content +// +//_links FileLinksResponse{...} +//content string +//content is populated when type is file, otherwise null +// +//download_url string +//encoding string +//encoding is populated when type is file, otherwise null +// +//git_url string +//html_url string +//last_commit_sha string +//name string +//path string +//sha string +//size integer($int64) +//submodule_git_url string +//submodule_git_url is populated when type is submodule, otherwise null +// +//target string +//target is populated when type is symlink, otherwise null +// +//type string +//type will be file, dir, symlink, or submodule +// +//url string +//} +//verification PayloadCommitVerification{ +//description: +//PayloadCommitVerification represents the GPG verification of a commit +// +//payload string +//reason string +//signature string +//signer PayloadUser{...} +//verified boolean +//} +//} diff --git a/src/types/api/general_api_settings.rs b/src/types/api/general_api_settings.rs new file mode 100644 index 0000000..0b4d7ad --- /dev/null +++ b/src/types/api/general_api_settings.rs @@ -0,0 +1,9 @@ +//GeneralAPISettings{ +//description: +//GeneralAPISettings contains global api settings exposed by it +// +//default_git_trees_per_page integer($int64) +//default_max_blob_size integer($int64) +//default_paging_num integer($int64) +//max_response_items integer($int64) +//} diff --git a/src/types/api/mod.rs b/src/types/api/mod.rs index 8ea8c3b..deb5d44 100644 --- a/src/types/api/mod.rs +++ b/src/types/api/mod.rs @@ -15,6 +15,7 @@ pub mod user; /* to-todo */ pub mod access_token; /* to-todo */ pub mod activity; +/* to-todo */ pub mod activity_pub; /* to-todo */ pub mod add; /* to-todo */ pub mod annotated_tag; /* to-todo */ pub mod annotated_tag_object; @@ -22,8 +23,11 @@ pub mod access_token; /* to-todo */ pub mod api_settings; /* to-todo */ pub mod attachment; /* to-todo */ pub mod attachment_settings; +/* to-todo */ pub mod blocked_user; /* to-todo */ pub mod branch; /* to-todo */ pub mod branch_protection; +/* to-todo */ pub mod change_file_operation; +/* to-todo */ pub mod change_file_options; /* to-todo */ pub mod changed_file; /* to-todo */ pub mod combined_status; /* to-todo */ pub mod comment; @@ -37,9 +41,17 @@ pub mod access_token; /* to-todo */ pub mod commit_user; /* to-todo */ pub mod content_response; /* to-todo */ pub mod create_hook_option_config; +/* to-todo */ pub mod cron; +/* to-todo */ pub mod delete_email; +/* to-todo */ pub mod delete_file; /* to-todo */ pub mod deploy_key; /* to-todo */ pub mod dismiss_pull_review; +/* to-todo */ pub mod email; +/* to-todo */ pub mod file_commit_response; +/* to-todo */ pub mod file_delete_response; /* to-todo */ pub mod file_link_response; +/* to-todo */ pub mod file_response; +/* to-todo */ pub mod general_api_settings; /* to-todo */ pub mod git_blob; /* to-todo */ pub mod git_entry; /* to-todo */ pub mod git_hook;