From c1660c4225e29520538f6bd18d042cc53e740336 Mon Sep 17 00:00:00 2001 From: Niel Drummond Date: Sat, 1 Feb 2025 17:20:32 +0000 Subject: [PATCH] feat: Split library into roctokit and roctogen --- .github/workflows/check.yml | 11 - .github/workflows/default.yml | 19 +- .gitignore | 2 +- Cargo.toml | 89 +------- README.md | 190 ++---------------- codegen/templates/api.mustache | 2 +- codegen/templates/lib.mustache | 8 +- core/Cargo.toml | 88 ++++++++ core/README.md | 120 +++++++++++ {src => core/src}/adapters/mod.rs | 0 {src => core/src}/adapters/reqwest.rs | 0 {src => core/src}/adapters/ureq.rs | 0 {src => core/src}/adapters/wasm.rs | 0 {src => core/src}/lib.rs | 37 ++-- {tests => core/tests}/simple.rs | 48 +++-- .../__files/body-gists-public-jAiWv.json | 0 .../stubs/__files/body-licenses-MMedz.json | 0 .../body-licenses-unlicense-7CKkm.json | 0 .../tests}/stubs/__files/body-meta-UpvZy.json | 0 .../stubs/__files/body-rate_limit-WEcsT.json | 0 ...r-protection-restrictions-users-9ARKG.json | 0 ...pos-fussybeaver-bollard-commits-MzcU8.json | 0 ...pos-fussybeaver-bollard-commits-XlXSM.json | 0 ...epos-fussybeaver-bollard-events-GsS4J.json | 0 ...epos-fussybeaver-bollard-issues-68wNX.json | 0 ...ver-bollard-issues-86-reactions-v1oBT.json | 0 ...ybeaver-bollard-issues-comments-2RXrT.json | 0 ...ssybeaver-bollard-issues-events-JDYdG.json | 0 ...epos-fussybeaver-bollard-labels-157cI.json | 0 ...pos-fussybeaver-bollard-license-DMLLq.json | 0 ...-fussybeaver-bollard-milestones-5fuAv.json | 0 ...fussybeaver-bollard-subscribers-lmpNw.json | 0 ...-does-not-exist-bollard-commits-pHO1B.json | 0 .../body-search-repositories-eeDr8.json | 0 ...body-users-fussybeaver-gpg_keys-H9I34.json | 0 ...body-users-fussybeaver-projects-iSt55.json | 0 .../body-users-fussybeaver-starred-tTWDw.json | 0 ...users-fussybeaver-subscriptions-wv2Q5.json | 0 .../stubs/__files/body-users-tXACn.json | 0 .../mappings/mapping-gists-public-jAiWv.json | 0 .../mappings/mapping-licenses-MMedz.json | 0 .../mapping-licenses-unlicense-7CKkm.json | 0 .../stubs/mappings/mapping-meta-UpvZy.json | 0 .../mappings/mapping-rate_limit-WEcsT.json | 0 ...r-protection-restrictions-users-9ARKG.json | 0 ...pos-fussybeaver-bollard-commits-MzcU8.json | 0 ...pos-fussybeaver-bollard-commits-XlXSM.json | 0 ...epos-fussybeaver-bollard-events-GsS4J.json | 0 ...epos-fussybeaver-bollard-issues-68wNX.json | 0 ...ver-bollard-issues-86-reactions-v1oBT.json | 0 ...ybeaver-bollard-issues-comments-2RXrT.json | 0 ...ssybeaver-bollard-issues-events-JDYdG.json | 0 ...epos-fussybeaver-bollard-labels-157cI.json | 0 ...pos-fussybeaver-bollard-license-DMLLq.json | 0 ...-fussybeaver-bollard-milestones-5fuAv.json | 0 ...fussybeaver-bollard-subscribers-lmpNw.json | 0 ...-does-not-exist-bollard-commits-pHO1B.json | 0 .../mapping-search-repositories-eeDr8.json | 0 ...ping-users-fussybeaver-gpg_keys-H9I34.json | 0 ...ping-users-fussybeaver-projects-iSt55.json | 0 ...pping-users-fussybeaver-starred-tTWDw.json | 0 ...users-fussybeaver-subscriptions-wv2Q5.json | 0 .../stubs/mappings/mapping-users-tXACn.json | 0 {tests => core/tests}/sync.rs | 18 +- .../auth/github-update-issue-bot/Cargo.toml | 6 +- .../auth/github-update-issue-bot/src/lib.rs | 7 +- examples/auth/wasm-jwt/Cargo.toml | 6 +- examples/auth/wasm-jwt/src/lib.rs | 6 +- examples/min-req-adapter/Cargo.toml | 3 +- examples/min-req-adapter/src/main.rs | 18 +- examples/search/Cargo.toml | 13 +- examples/search/src/main.rs | 21 +- pom.xml | 2 +- roctogen/Cargo.toml | 88 ++++++++ roctogen/README.md | 94 +++++++++ {src => roctogen/src}/endpoints/actions.rs | 2 +- {src => roctogen/src}/endpoints/activity.rs | 2 +- {src => roctogen/src}/endpoints/apps.rs | 2 +- {src => roctogen/src}/endpoints/billing.rs | 2 +- {src => roctogen/src}/endpoints/checks.rs | 2 +- {src => roctogen/src}/endpoints/classroom.rs | 2 +- .../src}/endpoints/code_scanning.rs | 2 +- .../src}/endpoints/code_security.rs | 2 +- .../src}/endpoints/codes_of_conduct.rs | 2 +- {src => roctogen/src}/endpoints/codespaces.rs | 2 +- {src => roctogen/src}/endpoints/copilot.rs | 2 +- {src => roctogen/src}/endpoints/dependabot.rs | 2 +- .../src}/endpoints/dependency_graph.rs | 2 +- {src => roctogen/src}/endpoints/emojis.rs | 2 +- {src => roctogen/src}/endpoints/gists.rs | 2 +- {src => roctogen/src}/endpoints/git.rs | 2 +- {src => roctogen/src}/endpoints/gitignore.rs | 2 +- .../src}/endpoints/hosted_compute.rs | 2 +- .../src}/endpoints/interactions.rs | 2 +- {src => roctogen/src}/endpoints/issues.rs | 2 +- {src => roctogen/src}/endpoints/licenses.rs | 2 +- {src => roctogen/src}/endpoints/markdown.rs | 2 +- {src => roctogen/src}/endpoints/meta.rs | 2 +- {src => roctogen/src}/endpoints/migrations.rs | 2 +- {src => roctogen/src}/endpoints/mod.rs | 0 {src => roctogen/src}/endpoints/oidc.rs | 2 +- {src => roctogen/src}/endpoints/orgs.rs | 2 +- {src => roctogen/src}/endpoints/packages.rs | 2 +- .../src}/endpoints/private_registries.rs | 2 +- {src => roctogen/src}/endpoints/projects.rs | 2 +- {src => roctogen/src}/endpoints/pulls.rs | 2 +- {src => roctogen/src}/endpoints/rate_limit.rs | 2 +- {src => roctogen/src}/endpoints/reactions.rs | 2 +- {src => roctogen/src}/endpoints/repos.rs | 2 +- {src => roctogen/src}/endpoints/search.rs | 2 +- .../src}/endpoints/secret_scanning.rs | 2 +- .../src}/endpoints/security_advisories.rs | 2 +- {src => roctogen/src}/endpoints/teams.rs | 2 +- {src => roctogen/src}/endpoints/users.rs | 2 +- roctogen/src/lib.rs | 120 +++++++++++ {src => roctogen/src}/models.rs | 0 116 files changed, 694 insertions(+), 398 deletions(-) delete mode 100644 .github/workflows/check.yml create mode 100644 core/Cargo.toml create mode 100644 core/README.md rename {src => core/src}/adapters/mod.rs (100%) rename {src => core/src}/adapters/reqwest.rs (100%) rename {src => core/src}/adapters/ureq.rs (100%) rename {src => core/src}/adapters/wasm.rs (100%) rename {src => core/src}/lib.rs (95%) rename {tests => core/tests}/simple.rs (84%) rename {tests => core/tests}/stubs/__files/body-gists-public-jAiWv.json (100%) rename {tests => core/tests}/stubs/__files/body-licenses-MMedz.json (100%) rename {tests => core/tests}/stubs/__files/body-licenses-unlicense-7CKkm.json (100%) rename {tests => core/tests}/stubs/__files/body-meta-UpvZy.json (100%) rename {tests => core/tests}/stubs/__files/body-rate_limit-WEcsT.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-commits-MzcU8.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-commits-XlXSM.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-events-GsS4J.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-issues-68wNX.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-issues-comments-2RXrT.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-issues-events-JDYdG.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-labels-157cI.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-license-DMLLq.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-milestones-5fuAv.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-fussybeaver-bollard-subscribers-lmpNw.json (100%) rename {tests => core/tests}/stubs/__files/body-repos-this-user-does-not-exist-bollard-commits-pHO1B.json (100%) rename {tests => core/tests}/stubs/__files/body-search-repositories-eeDr8.json (100%) rename {tests => core/tests}/stubs/__files/body-users-fussybeaver-gpg_keys-H9I34.json (100%) rename {tests => core/tests}/stubs/__files/body-users-fussybeaver-projects-iSt55.json (100%) rename {tests => core/tests}/stubs/__files/body-users-fussybeaver-starred-tTWDw.json (100%) rename {tests => core/tests}/stubs/__files/body-users-fussybeaver-subscriptions-wv2Q5.json (100%) rename {tests => core/tests}/stubs/__files/body-users-tXACn.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-gists-public-jAiWv.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-licenses-MMedz.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-licenses-unlicense-7CKkm.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-meta-UpvZy.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-rate_limit-WEcsT.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-MzcU8.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-XlXSM.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-events-GsS4J.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-68wNX.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-comments-2RXrT.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-events-JDYdG.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-labels-157cI.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-license-DMLLq.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-milestones-5fuAv.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-fussybeaver-bollard-subscribers-lmpNw.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-repos-this-user-does-not-exist-bollard-commits-pHO1B.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-search-repositories-eeDr8.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-users-fussybeaver-gpg_keys-H9I34.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-users-fussybeaver-projects-iSt55.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-users-fussybeaver-starred-tTWDw.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-users-fussybeaver-subscriptions-wv2Q5.json (100%) rename {tests => core/tests}/stubs/mappings/mapping-users-tXACn.json (100%) rename {tests => core/tests}/sync.rs (95%) create mode 100644 roctogen/Cargo.toml create mode 100644 roctogen/README.md rename {src => roctogen/src}/endpoints/actions.rs (99%) rename {src => roctogen/src}/endpoints/activity.rs (99%) rename {src => roctogen/src}/endpoints/apps.rs (99%) rename {src => roctogen/src}/endpoints/billing.rs (99%) rename {src => roctogen/src}/endpoints/checks.rs (99%) rename {src => roctogen/src}/endpoints/classroom.rs (99%) rename {src => roctogen/src}/endpoints/code_scanning.rs (99%) rename {src => roctogen/src}/endpoints/code_security.rs (99%) rename {src => roctogen/src}/endpoints/codes_of_conduct.rs (98%) rename {src => roctogen/src}/endpoints/codespaces.rs (99%) rename {src => roctogen/src}/endpoints/copilot.rs (99%) rename {src => roctogen/src}/endpoints/dependabot.rs (99%) rename {src => roctogen/src}/endpoints/dependency_graph.rs (99%) rename {src => roctogen/src}/endpoints/emojis.rs (97%) rename {src => roctogen/src}/endpoints/gists.rs (99%) rename {src => roctogen/src}/endpoints/git.rs (99%) rename {src => roctogen/src}/endpoints/gitignore.rs (98%) rename {src => roctogen/src}/endpoints/hosted_compute.rs (99%) rename {src => roctogen/src}/endpoints/interactions.rs (99%) rename {src => roctogen/src}/endpoints/issues.rs (99%) rename {src => roctogen/src}/endpoints/licenses.rs (99%) rename {src => roctogen/src}/endpoints/markdown.rs (98%) rename {src => roctogen/src}/endpoints/meta.rs (99%) rename {src => roctogen/src}/endpoints/migrations.rs (99%) rename {src => roctogen/src}/endpoints/mod.rs (100%) rename {src => roctogen/src}/endpoints/oidc.rs (99%) rename {src => roctogen/src}/endpoints/orgs.rs (99%) rename {src => roctogen/src}/endpoints/packages.rs (99%) rename {src => roctogen/src}/endpoints/private_registries.rs (99%) rename {src => roctogen/src}/endpoints/projects.rs (99%) rename {src => roctogen/src}/endpoints/pulls.rs (99%) rename {src => roctogen/src}/endpoints/rate_limit.rs (99%) rename {src => roctogen/src}/endpoints/reactions.rs (99%) rename {src => roctogen/src}/endpoints/repos.rs (99%) rename {src => roctogen/src}/endpoints/search.rs (99%) rename {src => roctogen/src}/endpoints/secret_scanning.rs (99%) rename {src => roctogen/src}/endpoints/security_advisories.rs (99%) rename {src => roctogen/src}/endpoints/teams.rs (99%) rename {src => roctogen/src}/endpoints/users.rs (99%) create mode 100644 roctogen/src/lib.rs rename {src => roctogen/src}/models.rs (100%) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 168cbdb..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Check -on: - repository_dispatch: - types: - - octokit/openapi-release - -jobs: - update: - runs-on: ubuntu-latest - steps: - - run: echo "${{ github.event }}" diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 24abd1e..d7c321a 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -47,23 +47,30 @@ jobs: command: check args: --target wasm32-unknown-unknown - - name: Run cargo check workspace examples + - name: Run cargo check example wasm-jwt uses: actions-rs/cargo@v1 with: command: check - args: -p roctogen-common -p roctogen-github-update-issue-bot -p roctogen-jwt-example --target wasm32-unknown-unknown + args: --manifest-path examples/auth/wasm-jwt/Cargo.toml --target wasm32-unknown-unknown - - name: Run cargo check min-req-adapter + - name: Run cargo check example github-update-issue-bot uses: actions-rs/cargo@v1 with: command: check - args: -p min-req-adapter + args: --manifest-path examples/auth/github-update-issue-bot/Cargo.toml --target wasm32-unknown-unknown + + - name: Run cargo check example min-req-adapter + uses: actions-rs/cargo@v1 + with: + command: check + args: --manifest-path examples/min-req-adapter/Cargo.toml - - name: Run cargo check search + - name: Run cargo check example search uses: actions-rs/cargo@v1 + with: command: check - args: -p search + args: --manifest-path examples/search/Cargo.toml test: name: Test Suite diff --git a/.gitignore b/.gitignore index 01f1da2..581743a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,5 @@ target/ /.project /generated-sources /.cargo -/Cargo.lock +Cargo.lock /.idea diff --git a/Cargo.toml b/Cargo.toml index bc57c0d..a796977 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,34 +1,17 @@ -[package] -name = "roctogen" -version = "0.12.0" -authors = [ "Roctogen contributors" ] -description = "Github API and models generated from the official swagger OpenAPI specification" -license = "Apache-2.0" -homepage = "https://github.com/fussybeaver/roctogen" -repository = "https://github.com/fussybeaver/roctogen" -documentation = "https://docs.rs/roctogen" -readme = "README.md" -keywords = ["github"] -edition = "2021" - [workspace] members = [ + "roctogen", "examples/auth/*", "examples/min-req-adapter", - "examples/search", + "core", ] -exclude = ["codegen/**"] - -[lib] -crate-type = ["cdylib", "rlib"] -path = "src/lib.rs" - -[features] -default = [] -reqwest = ["dep:reqwest", "dep:bytes"] - -# Activate mock base url -mock = [] +exclude = [ + "codegen/**", + "examples/auth/*", + "examples/min-req-adapter", + "examples/search" +] +resolver = "3" [workspace.dependencies] base64 = "0.22" @@ -50,57 +33,7 @@ wee_alloc = { version = "0.4.2" } js-sys = { version = "0.3" } web-sys = { version = "0.3", features = [ 'Headers', 'Request', 'RequestInit', 'Response', 'ServiceWorkerGlobalScope', 'Window', 'console' ] } console_log = { version = "1", features = ["color"] } +roctokit = { path = "core" } +roctogen = { path = "roctogen" } -[dependencies] -base64.workspace = true -chrono.workspace = true -http.workspace = true -serde.workspace = true -serde_derive.workspace = true -serde_json.workspace = true -serde_urlencoded.workspace = true -thiserror.workspace = true -log.workspace = true -bytes = { version = "1", optional = true } - -# reqwest -reqwest = { version = "0.12", optional = true, features = [] } - -# ureq -ureq = { version = "3.0.3", optional = true, features = ["json"] } - -# wasm -[target.'cfg(target_arch = "wasm32")'.dependencies] -cfg-if = { version = "1" } -wasm-bindgen = { version = "0.2.95", features = ["serde-serialize"] } -wasm-bindgen-futures = { version = "0.4" } -console_error_panic_hook = { version = "0.1.1" } -wee_alloc = { version = "0.4.2" } -js-sys = { version = "0.3" } - -[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys] -version = "0.3" -features = [ - 'Headers', - 'Request', - 'RequestInit', - 'Response', - 'ServiceWorkerGlobalScope', - 'Window', - 'console', -] - -[target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen-test = "0.3.45" -console_log = { workspace = true, features = ["color"] } - -[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] -futures-lite = { version = "2.3" } -futures-io = { version = "0.3" } -futures-core = { version = "0.3" } -tokio = { version = "1.2", default-features = false, features = ["macros", "rt-multi-thread"] } -env_logger = "0.11" -[package.metadata.docs.rs] -default-target = "x86_64-unknown-linux-gnu" -targets = ["wasm32-unknown-unknown"] diff --git a/README.md b/README.md index c934350..9cd0149 100644 --- a/README.md +++ b/README.md @@ -2,189 +2,31 @@ [![docs](https://docs.rs/roctogen/badge.svg)](https://docs.rs/roctogen/) [![GitHub workflow](https://github.com/fussybeaver/roctogen/actions/workflows/default.yml/badge.svg)](https://github.com/fussybeaver/roctogen/actions/workflows/default.yml) -## Roctogen: Rust Client Library for GitHub v3 API +## Roctokit: Rust Client Library for GitHub v3 API -**Roctogen** is a Rust library generated from the [GitHub REST API OpenAPI -specification](https://github.com/github/rest-api-description/). providing -comprehensive support for the GitHub v3 API. It offers flexible support for -both synchronous and asynchronous HTTP clients, including WebAssembly -compatibility. You can choose between multiple client libraries via Cargo -features, or integrate your own HTTP client handling by extending the -`adapter` subsytem: +**Roctokit** is a Rust library containing client interfaces for models and endpoints generated from the [GitHub REST API OpenAPI +specification](https://github.com/github/rest-api-description/), providing comprehensive support for the GitHub v3 API. - - `reqwest`: Enables asynchronous requests using the [Reqwest client](https://github.com/seanmonstar/reqwest) - - `ureq`: Provides synchronous requests with the [Ureq client](https://github.com/algesten/ureq) - -### Installation - -To include Roctogen in your project, add it to your `Cargo.toml`: - -```nocompile -[dependencies] -roctogen = "*" -``` - -### Documentation - -- [API docs](https://docs.rs/roctogen/latest). -- [Endpoints](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html). - -#### Supported endpoints: - -Roctogen supports a wide range of GitHub API endpoints, including: - - - [Meta](https://docs.rs/roctogen/latest/roctogen/endpoints/meta/struct.Meta.html) - - [Issues](https://docs.rs/roctogen/latest/roctogen/endpoints/issues/struct.Issues.html) - - [Licenses](https://docs.rs/roctogen/latest/roctogen/endpoints/licenses/struct.Licenses.html) - - [Reactions](https://docs.rs/roctogen/latest/roctogen/endpoints/reactions/struct.Reactions.html) - - [Activity](https://docs.rs/roctogen/latest/roctogen/endpoints/activity/struct.Activity.html) - - [Projects](https://docs.rs/roctogen/latest/roctogen/endpoints/projects/struct.Projects.html) - - [Orgs](https://docs.rs/roctogen/latest/roctogen/endpoints/orgs/struct.Orgs.html) - - [Users](https://docs.rs/roctogen/latest/roctogen/endpoints/users/struct.Users.html) - - [Apps](https://docs.rs/roctogen/latest/roctogen/endpoints/apps/struct.Apps.html) - - [RateLimit](https://docs.rs/roctogen/latest/roctogen/endpoints/rate_limit/struct.RateLimit.html) - - [Repos](https://docs.rs/roctogen/latest/roctogen/endpoints/repos/struct.Repos.html) - - [SecretScanning](https://docs.rs/roctogen/latest/roctogen/endpoints/secret_scanning/struct.SecretScanning.html) - - [SecurityAdvisories](https://docs.rs/roctogen/latest/roctogen/endpoints/security_advisories/struct.SecurityAdvisories.html) - - [Packages](https://docs.rs/roctogen/latest/roctogen/endpoints/packages/struct.Packages.html) - - [Search](https://docs.rs/roctogen/latest/roctogen/endpoints/search/struct.Search.html) - - [Classroom](https://docs.rs/roctogen/latest/roctogen/endpoints/classroom/struct.Classroom.html) - - [Teams](https://docs.rs/roctogen/latest/roctogen/endpoints/teams/struct.Teams.html) - - [PrivateRegistries](https://docs.rs/roctogen/latest/roctogen/endpoints/private_registries/struct.PrivateRegistries.html) - - [Oidc](https://docs.rs/roctogen/latest/roctogen/endpoints/oidc/struct.Oidc.html) - - [Markdown](https://docs.rs/roctogen/latest/roctogen/endpoints/markdown/struct.Markdown.html) - - [Actions](https://docs.rs/roctogen/latest/roctogen/endpoints/actions/struct.Actions.html) - - [Migrations](https://docs.rs/roctogen/latest/roctogen/endpoints/migrations/struct.Migrations.html) - - [CodeSecurity](https://docs.rs/roctogen/latest/roctogen/endpoints/code_security/struct.CodeSecurity.html) - - [Gists](https://docs.rs/roctogen/latest/roctogen/endpoints/gists/struct.Gists.html) - - [DependencyGraph](https://docs.rs/roctogen/latest/roctogen/endpoints/dependency_graph/struct.DependencyGraph.html) - - [Copilot](https://docs.rs/roctogen/latest/roctogen/endpoints/copilot/struct.Copilot.html) - - [Dependabot](https://docs.rs/roctogen/latest/roctogen/endpoints/dependabot/struct.Dependabot.html) - - [CodesOfConduct](https://docs.rs/roctogen/latest/roctogen/endpoints/codes_of_conduct/struct.CodesOfConduct.html) - - [Pulls](https://docs.rs/roctogen/latest/roctogen/endpoints/pulls/struct.Pulls.html) - - [Gitignore](https://docs.rs/roctogen/latest/roctogen/endpoints/gitignore/struct.Gitignore.html) - - [Git](https://docs.rs/roctogen/latest/roctogen/endpoints/git/struct.Git.html) - - [CodeScanning](https://docs.rs/roctogen/latest/roctogen/endpoints/code_scanning/struct.CodeScanning.html) - - [Checks](https://docs.rs/roctogen/latest/roctogen/endpoints/checks/struct.Checks.html) - - [Billing](https://docs.rs/roctogen/latest/roctogen/endpoints/billing/struct.Billing.html) - - [Interactions](https://docs.rs/roctogen/latest/roctogen/endpoints/interactions/struct.Interactions.html) - - [Codespaces](https://docs.rs/roctogen/latest/roctogen/endpoints/codespaces/struct.Codespaces.html) - - [Emojis](https://docs.rs/roctogen/latest/roctogen/endpoints/emojis/struct.Emojis.html) - -For a full list of supported endpoints, refer to the [API documentation](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html). - -### Usage - -Here's a basic example demonstrating how to use Roctogen: - -```rust -use roctogen::api::{self, repos}; -use roctogen::adapters::client; -use roctogen::auth::Auth; - -let auth = Auth::None; -let client = client(&auth).expect("Cannot create new client"); -let per_page = api::PerPage::new(10); - -let mut params: repos::ReposListCommitsParams = per_page.as_ref().into(); -params = params.author("fussybeaver").page(2); - -repos::new(&client).list_commits("fussybeaver", "bollard", Some(params)); -``` - -#### Asynchronous Requests - -For async support, use the `_async` suffix for method calls. These are -available with the `reqwest`, or WebAssembly targets. - -#### Webassembly - -Roctogen can be compiled to WebAssembly using -[`wasm-pack`](https://github.com/rustwasm/wasm-pack) or by directly -targeting wasm32-unknown-unknown: +**Roctokit** provides stock interfaces supporting both synchronous and asynchronous HTTP clients, including WebAssembly compatibility. More flexible implementations such as [handling GitHub's rate limiting or building streams out of paginated results](./examples/search) is also available by extending the `adapter` subsystem. -```nocompile -$ wasm-pack build -``` +### Stock client interfaces -```nocompile -$ cargo build --target wasm32-unknown-unknown -``` - -### Client adapters - -Roctogen supports multiple HTTP clients, or you can write your own. Enable -the desired client using Cargo features: - -#### Reqwest - -Compile with Reqwest support using the `reqwest` feature: - -```nocompile -$ cargo build --features reqwest -``` - -#### Ureq - -Compile with Ureq support using the `ureq` feature: - -```nocompile -$ cargo build --features ureq -``` - -#### Custom Client Adapters - -It's possible to write your own adapter, by extending -`roctogen::adapters::Client`. This allows you to handle rate limiting and -pagination - an example of extending the base adapter is available in the -example [`min-req-adapter`](/fussybeaver/roctogen/tree/master/examples/min-req-adapter). - -### Generating the API - -Roctogen's code is largely generated from the GitHub REST API specification -using the [Swagger OpenAPI -generator](https://github.com/swagger-api/swagger-codegen) (version 3). -Building the API requires the Java-based `mvn` tool with JDK 8 installed: - -```nocompile -$ mvn -D org.slf4j.simpleLogger.defaultLogLevel=info clean compiler:compile generate-resources -``` - -### Testing - -Roctogen supports both WebAssembly and synchronous test environments. Be -aware that some tests perform real HTTP requests to the GitHub API unless -mocked. - -- **WebAssembly Tests**: - -```nocompile -$ wasm-pack test --firefox --headless -``` - -- ** **Synchronous Tests**: + - `reqwest`: Enables asynchronous requests using the [Reqwest client](https://github.com/seanmonstar/reqwest) +- `ureq`: Provides synchronous requests with the [Ureq client](https://github.com/algesten/ureq) + - `wasm`: Use a wasm interface with the underlying [fetch API](TODO). -```nocompile -$ cargo test --features isahc,mercy,squirrel-girl,inertia,starfox --target x86_64-unknown-linux-gnu -- --nocapture -``` +### Repository Structure -To avoid GitHub's API rate limits during testing, you can use WireMock to -mock the API locally. Run the following to start WireMock, and run the -tests with the `--mock` feature: +This repository is split into two main components: -```nocompile -$ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock -rodolpheche/wiremock -$ cargo test --feature mock,ureq -``` +- [roctogen](./roctogen/README.md): A Rust library generated from the GitHub REST API OpenAPI specification, providing models and low-level API bindings. -#### Regenerate the wiremock stubs +- [roctokit](./roctokit/README.md): Higher-level abstractions for interacting with the generated GitHub models. -If the GitHub API changes, you can regenerate the WireMock stubs: +### Getting Started -```nocompile -$ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock -u (id -u):(id -g) rodolpheche/wiremock --verbose --proxy-all="https://api.github.com" --record-mappings -``` +An simple example is explained in the [roctogen README](./roctogen/README.md#Usage). Following this, refer to the [endpoints documentation](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html) to understand which GitHub API to use. +### License -License: Apache-2.0 +This project is licensed under the Apache 2.0 License. diff --git a/codegen/templates/api.mustache b/codegen/templates/api.mustache index c5f9ab1..922b9f1 100644 --- a/codegen/templates/api.mustache +++ b/codegen/templates/api.mustache @@ -6,7 +6,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/codegen/templates/lib.mustache b/codegen/templates/lib.mustache index 0a996f0..77c3f8f 100644 --- a/codegen/templates/lib.mustache +++ b/codegen/templates/lib.mustache @@ -22,6 +22,7 @@ //! ```nocompile //! [dependencies] //! roctogen = "*" +//! roctokit = "*" //! ``` //! //! ## Documentation @@ -43,8 +44,8 @@ //! //! ```no_run //! use roctogen::api::{self, repos}; -//! use roctogen::adapters::client; -//! use roctogen::auth::Auth; +//! use roctokit::adapters::client; +//! use roctokit::auth::Auth; //! //! let auth = Auth::None; //! let client = client(&auth).expect("Cannot create new client"); @@ -139,7 +140,7 @@ //! ```nocompile //! $ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock //! rodolpheche/wiremock -//! $ cargo test --feature mock,ureq +//! $ cargo test --features mock,ureq //! ``` //! //! ### Regenerate the wiremock stubs @@ -160,7 +161,6 @@ extern crate serde_derive; use std::collections::HashMap; -pub mod adapters; pub mod endpoints; pub mod models; diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 0000000..dfabb4c --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,88 @@ +[package] +name = "roctokit" +version = "0.13.0" +authors = [ "Roctokit contributors" ] +description = "Github v3 Client API" +license = "Apache-2.0" +homepage = "https://github.com/fussybeaver/roctogen" +repository = "https://github.com/fussybeaver/roctogen" +documentation = "https://docs.rs/roctogen" +readme = "README.md" +keywords = ["github"] +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] +path = "src/lib.rs" + +[features] +default = [] +reqwest = ["dep:reqwest", "dep:bytes"] +mock = ["roctogen/mock"] + +[dependencies] +base64 = "0.22" +chrono = { version = "0.4", features = ["serde"] } +http = "1.1" +serde = "1.0" +serde_derive = "1.0" +serde_json = {version = "1.0"} +serde_urlencoded = { version = "0.7" } +thiserror = "1" +log = "0.4" + +# wasm +cfg-if = { version = "1" } +wasm-bindgen = { version = "0.2.95", features = ["serde-serialize"] } +wasm-bindgen-futures = { version = "0.4" } +console_error_panic_hook = { version = "0.1.1" } +wee_alloc = { version = "0.4.2" } +js-sys = { version = "0.3" } +web-sys = { version = "0.3", features = [ 'Headers', 'Request', 'RequestInit', 'Response', 'ServiceWorkerGlobalScope', 'Window', 'console' ] } +console_log = { version = "1", features = ["color"] } + +bytes = { version = "1", optional = true } + +# reqwest +reqwest = { version = "0.12", optional = true, features = [] } + +# ureq +ureq = { version = "3.0.3", optional = true, features = ["json"] } + +[dev-dependencies] +roctogen = { path = "../roctogen", version = "*" } + +# wasm +[target.'cfg(target_arch = "wasm32")'.dependencies] +cfg-if = { version = "1" } +wasm-bindgen = { version = "0.2.95", features = ["serde-serialize"] } +wasm-bindgen-futures = { version = "0.4" } +console_error_panic_hook = { version = "0.1.1" } +wee_alloc = { version = "0.4.2" } +js-sys = { version = "0.3" } + +[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys] +version = "0.3" +features = [ + 'Headers', + 'Request', + 'RequestInit', + 'Response', + 'ServiceWorkerGlobalScope', + 'Window', + 'console', +] + +[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +wasm-bindgen-test = "0.3.45" + +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +futures-lite = { version = "2.3" } +futures-io = { version = "0.3" } +futures-core = { version = "0.3" } +tokio = { version = "1.2", default-features = false, features = ["macros", "rt-multi-thread"] } +env_logger = "0.11" + +[package.metadata.docs.rs] +default-target = "x86_64-unknown-linux-gnu" +targets = ["wasm32-unknown-unknown"] diff --git a/core/README.md b/core/README.md new file mode 100644 index 0000000..f779e71 --- /dev/null +++ b/core/README.md @@ -0,0 +1,120 @@ +## Roctokit [core]: Rust interfaces to a generated GitHub v3 API + +**Roctokit** provides stock interfaces supporting both synchronous and asynchronous HTTP clients, including WebAssembly compatibility. + +Interfaces are generic by extending the `adapter` subsystem, which should give you features you'll need for a production system. + +This library is intended to be used in conjunction with [roctogen's](TODO) generated API models and endpoints. + +### Getting Started + +If you just need to get started, use the cargo feature or target as appropriate: + +- Asynchronous requests using `reqwest`: `cargo build --feature reqwest` +- Synchronous requests using `ureq`: `cargo build --feature ureq` +- WebAssembly using: `cargo build --target wasm-unknown-unknown` + +Use both [roctogen](TODO) and [roctokit](TODO) as cargo dependencies in your `Cargo.toml`: + +```nocompile +[dependencies] +roctogen = "*" +roctokit = "*" +``` + +#### Client creation + +Parts of GitHub's v3 API and also it's rate limiting quotas are toggled through an authentication workflow. This is abstracted through an [`Auth`](TODO) struct, which is passed into the client. + +- Basic username/password auth: `Auth::Basic(user, pass)` +- Token: `Auth::Token(token)` +- Bearer: `Auth::Bearer(bearer)` +- Unauthenticated: `Auth::None` + +The client could be one of the stock interfaces, or a custom one implementing the generic base [`adaprer::Client`](TODO). If using the stock interfaces, `roctokit` provides a convenience method to instantiate the client, which is available as soon as the appropriate cargo feature is enabled. + +```rust +use roctokit::adapters::client; + +client(&auth).expect("Cannot create new client") +``` + +#### API's and endpoints + +Endpoints are generated by the [`roctogen`](TODO) library, navigating all available API's, parameters and models is best done through the generated [`roctogen` documentation](TODO). + +Additional documentation on building query parameter structs and calling endpoints with the client interface is available in the [`roctogen` README](TODO). + +### Custom Client Adapters + +Aside from the stock client interfaces, it's often desirable to write a client interface, allowing control over pagination,backpressure, and the underlying HTTP framework. This is a more advanced concept, and it's a good idea to review the [examples](../examples). + +Firstly, you will need to implement the [`adapters::Client`](TODO) interface: + +```rust +struct Client { +} + +impl rocotokit::adapters::Client for Client { + type Req = MyRequest; + type Err = MyError; + type Body = Vec; + + // ... +} +``` + +A Client is used by `roctogen`'s generated API to build a request object containing authentication parameters, send it using a desired HTTP framework and deserialise the response into an type known by `roctogen`. + + - `type Req`: A request type compatible with the underlying HTTP framework. + - `type Err`: An error type for this client that must have a `From` implementation to `roctokit::adapters::AdapterError`. + - `type Body`: A POST/PUT HTTP payload type used by the underlying HTTP framework. + +The underlying methods to the `Client` that need implementing: + + - `new`: Construct the client struct. + - `build`: Construct a user specified `type Req` from a `roctogen` `GithubRequest`, which can then be used with the desired HTTP framework. + - `fetch` / `fetch_async`: a synchronous and asynchronous mechanism to send the `type Req` payload. + - `from_json`: A mechanism to serialise a `roctogen` model to a `type Body` payload. + +In addition, the `GithubResponseExt` should be implemented for the response type sent by the desired HTTP framework. This trait contains: + + - `is_success`: determine whether the response was successful and should generate an error. + - `status_code`: return the status code of the response. + - `to_json` / `to_json_async`: A synchronous or asynchronous method to deserialise the json from the payload. + +### Testing + +Be aware that, by default, tests perform real HTTP requests to the GitHub API. Some of these may be offloaded to a wiremock server that serves generated stubs using the `mock` feature. + +- **WebAssembly Tests**: + +```nocompile +$ wasm-pack test --firefox --headless +``` + +- ** **Synchronous Tests**: + +```nocompile +$ cargo test --target x86_64-unknown-linux-gnu -- --nocapture +``` + +To avoid GitHub's API rate limits during testing, you can use WireMock to +mock the API locally. Run the following to start WireMock, and run the +tests with the `--mock` feature: + +```nocompile +$ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock +rodolpheche/wiremock +$ cargo test --features mock,ureq +``` + +#### Regenerate the wiremock stubs + +If the GitHub API changes, you can regenerate the WireMock stubs: + +```nocompile +$ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock -u (id -u):(id -g) rodolpheche/wiremock --verbose --proxy-all="https://api.github.com" --record-mappings +``` + +License: Apache-2.0 diff --git a/src/adapters/mod.rs b/core/src/adapters/mod.rs similarity index 100% rename from src/adapters/mod.rs rename to core/src/adapters/mod.rs diff --git a/src/adapters/reqwest.rs b/core/src/adapters/reqwest.rs similarity index 100% rename from src/adapters/reqwest.rs rename to core/src/adapters/reqwest.rs diff --git a/src/adapters/ureq.rs b/core/src/adapters/ureq.rs similarity index 100% rename from src/adapters/ureq.rs rename to core/src/adapters/ureq.rs diff --git a/src/adapters/wasm.rs b/core/src/adapters/wasm.rs similarity index 100% rename from src/adapters/wasm.rs rename to core/src/adapters/wasm.rs diff --git a/src/lib.rs b/core/src/lib.rs similarity index 95% rename from src/lib.rs rename to core/src/lib.rs index 60c9158..3618dba 100644 --- a/src/lib.rs +++ b/core/src/lib.rs @@ -13,7 +13,7 @@ //! `adapter` subsytem: //! //! - `reqwest`: Enables asynchronous requests using the [Reqwest client](https://github.com/seanmonstar/reqwest) -//! - `ureq`: Provides synchronous requests with the [Ureq client](https://github.com/algesten/ureq) +//! - `ureq`: Provides synchronous requests with the [Ureq client](https://github.com/algesten/ureq) //! //! ## Installation //! @@ -30,9 +30,9 @@ //! - [Endpoints](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html). //! //! ### Supported endpoints: -//! +//! //! Roctogen supports a wide range of GitHub API endpoints, including: -//! +//! //! - [Meta](https://docs.rs/roctogen/latest/roctogen/endpoints/meta/struct.Meta.html) //! - [Issues](https://docs.rs/roctogen/latest/roctogen/endpoints/issues/struct.Issues.html) //! - [Licenses](https://docs.rs/roctogen/latest/roctogen/endpoints/licenses/struct.Licenses.html) @@ -80,13 +80,13 @@ //! //! ```no_run //! use roctogen::api::{self, repos}; -//! use roctogen::adapters::client; -//! use roctogen::auth::Auth; +//! use roctokit::adapters::client; +//! use roctokit::auth::Auth; //! //! let auth = Auth::None; //! let client = client(&auth).expect("Cannot create new client"); //! let per_page = api::PerPage::new(10); -//! +//! //! let mut params: repos::ReposListCommitsParams = per_page.as_ref().into(); //! params = params.author("fussybeaver").page(2); //! @@ -151,7 +151,7 @@ //! $ mvn -D org.slf4j.simpleLogger.defaultLogLevel=info clean compiler:compile generate-resources //! ``` //! -//! ## Testing +//! ## Testing //! //! Roctogen supports both WebAssembly and synchronous test environments. Be //! aware that some tests perform real HTTP requests to the GitHub API unless @@ -160,7 +160,7 @@ //! - **WebAssembly Tests**: //! //! ```nocompile -//! $ wasm-pack test --firefox --headless +//! $ wasm-pack test --firefox --headless //! ``` //! //! - ** **Synchronous Tests**: @@ -187,32 +187,19 @@ //! $ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock -u (id -u):(id -g) rodolpheche/wiremock --verbose --proxy-all="https://api.github.com" --record-mappings //! ``` //! -#![allow( - missing_docs, - unused_imports, -)] - -#[macro_use] -extern crate serde_derive; +#![allow(missing_docs, unused_imports)] use std::collections::HashMap; -pub mod adapters; -pub mod endpoints; -pub mod models; - pub mod auth { - + #[derive(Clone, Debug)] pub enum Auth { - Basic { - user: String, - pass: String, - }, + Basic { user: String, pass: String }, Token(String), Bearer(String), None, } } -pub use endpoints as api; +pub mod adapters; diff --git a/tests/simple.rs b/core/tests/simple.rs similarity index 84% rename from tests/simple.rs rename to core/tests/simple.rs index d3225e4..7d934e7 100644 --- a/tests/simple.rs +++ b/core/tests/simple.rs @@ -2,13 +2,9 @@ use wasm_bindgen_test::*; use roctogen::api::{self, repos}; -use roctogen::{auth::Auth}; -#[cfg(any( - feature = "reqwest", - feature = "ureq", - target_arch = "wasm32" -))] -use roctogen::adapters::client; +#[cfg(any(feature = "reqwest", feature = "ureq", target_arch = "wasm32"))] +use roctokit::adapters::client; +use roctokit::auth::Auth; use roctogen::models; @@ -37,7 +33,11 @@ async fn get_wasm_fail() { .await; match &req { Ok(_) => {} - Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + Err(roctokit::adapters::AdapterError::Endpoint { + description, + status_code: 404, + .. + }) => { debug!("{}", description); } Err(_) => { @@ -60,7 +60,11 @@ fn get_sync_fail() { repos::new(&client).list_commits("this-user-does-not-exist", "bollard", Some(&per_page)); match &req { Ok(_) => {} - Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + Err(roctokit::adapters::AdapterError::Endpoint { + description, + status_code: 404, + .. + }) => { debug!("{}", description); } Err(x) => { @@ -152,7 +156,11 @@ async fn get_async_fail() { .await; match &req { Ok(_) => {} - Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + Err(roctokit::adapters::AdapterError::Endpoint { + description, + status_code: 404, + .. + }) => { debug!("{}", description); } Err(x) => { @@ -181,7 +189,11 @@ async fn post_wasm_fail() { .await; match &req { Ok(_) => {} - Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + Err(roctokit::adapters::AdapterError::Endpoint { + description, + status_code: 404, + .. + }) => { debug!("{}", description); } Err(_) => { @@ -206,7 +218,11 @@ fn post_sync_fail() { repos::new(&client).add_user_access_restrictions("fussybeaver", "bollard", "master", body); match &req { Ok(_) => {} - Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + Err(roctokit::adapters::AdapterError::Endpoint { + description, + status_code: 404, + .. + }) => { debug!("{}", description); } Err(_) => { @@ -233,7 +249,13 @@ async fn post_async_fail() { .await; match &req { Ok(_) => {} - Err(e @ roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + Err( + e @ roctokit::adapters::AdapterError::Endpoint { + description, + status_code: 404, + .. + }, + ) => { debug!("{:?}", e); } Err(_) => { diff --git a/tests/stubs/__files/body-gists-public-jAiWv.json b/core/tests/stubs/__files/body-gists-public-jAiWv.json similarity index 100% rename from tests/stubs/__files/body-gists-public-jAiWv.json rename to core/tests/stubs/__files/body-gists-public-jAiWv.json diff --git a/tests/stubs/__files/body-licenses-MMedz.json b/core/tests/stubs/__files/body-licenses-MMedz.json similarity index 100% rename from tests/stubs/__files/body-licenses-MMedz.json rename to core/tests/stubs/__files/body-licenses-MMedz.json diff --git a/tests/stubs/__files/body-licenses-unlicense-7CKkm.json b/core/tests/stubs/__files/body-licenses-unlicense-7CKkm.json similarity index 100% rename from tests/stubs/__files/body-licenses-unlicense-7CKkm.json rename to core/tests/stubs/__files/body-licenses-unlicense-7CKkm.json diff --git a/tests/stubs/__files/body-meta-UpvZy.json b/core/tests/stubs/__files/body-meta-UpvZy.json similarity index 100% rename from tests/stubs/__files/body-meta-UpvZy.json rename to core/tests/stubs/__files/body-meta-UpvZy.json diff --git a/tests/stubs/__files/body-rate_limit-WEcsT.json b/core/tests/stubs/__files/body-rate_limit-WEcsT.json similarity index 100% rename from tests/stubs/__files/body-rate_limit-WEcsT.json rename to core/tests/stubs/__files/body-rate_limit-WEcsT.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-commits-MzcU8.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-commits-MzcU8.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-commits-MzcU8.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-commits-MzcU8.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-commits-XlXSM.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-commits-XlXSM.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-commits-XlXSM.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-commits-XlXSM.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-events-GsS4J.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-events-GsS4J.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-events-GsS4J.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-events-GsS4J.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-68wNX.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-68wNX.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-issues-68wNX.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-68wNX.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-comments-2RXrT.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-comments-2RXrT.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-issues-comments-2RXrT.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-comments-2RXrT.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-events-JDYdG.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-events-JDYdG.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-issues-events-JDYdG.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-issues-events-JDYdG.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-labels-157cI.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-labels-157cI.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-labels-157cI.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-labels-157cI.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-license-DMLLq.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-license-DMLLq.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-license-DMLLq.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-license-DMLLq.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-milestones-5fuAv.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-milestones-5fuAv.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-milestones-5fuAv.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-milestones-5fuAv.json diff --git a/tests/stubs/__files/body-repos-fussybeaver-bollard-subscribers-lmpNw.json b/core/tests/stubs/__files/body-repos-fussybeaver-bollard-subscribers-lmpNw.json similarity index 100% rename from tests/stubs/__files/body-repos-fussybeaver-bollard-subscribers-lmpNw.json rename to core/tests/stubs/__files/body-repos-fussybeaver-bollard-subscribers-lmpNw.json diff --git a/tests/stubs/__files/body-repos-this-user-does-not-exist-bollard-commits-pHO1B.json b/core/tests/stubs/__files/body-repos-this-user-does-not-exist-bollard-commits-pHO1B.json similarity index 100% rename from tests/stubs/__files/body-repos-this-user-does-not-exist-bollard-commits-pHO1B.json rename to core/tests/stubs/__files/body-repos-this-user-does-not-exist-bollard-commits-pHO1B.json diff --git a/tests/stubs/__files/body-search-repositories-eeDr8.json b/core/tests/stubs/__files/body-search-repositories-eeDr8.json similarity index 100% rename from tests/stubs/__files/body-search-repositories-eeDr8.json rename to core/tests/stubs/__files/body-search-repositories-eeDr8.json diff --git a/tests/stubs/__files/body-users-fussybeaver-gpg_keys-H9I34.json b/core/tests/stubs/__files/body-users-fussybeaver-gpg_keys-H9I34.json similarity index 100% rename from tests/stubs/__files/body-users-fussybeaver-gpg_keys-H9I34.json rename to core/tests/stubs/__files/body-users-fussybeaver-gpg_keys-H9I34.json diff --git a/tests/stubs/__files/body-users-fussybeaver-projects-iSt55.json b/core/tests/stubs/__files/body-users-fussybeaver-projects-iSt55.json similarity index 100% rename from tests/stubs/__files/body-users-fussybeaver-projects-iSt55.json rename to core/tests/stubs/__files/body-users-fussybeaver-projects-iSt55.json diff --git a/tests/stubs/__files/body-users-fussybeaver-starred-tTWDw.json b/core/tests/stubs/__files/body-users-fussybeaver-starred-tTWDw.json similarity index 100% rename from tests/stubs/__files/body-users-fussybeaver-starred-tTWDw.json rename to core/tests/stubs/__files/body-users-fussybeaver-starred-tTWDw.json diff --git a/tests/stubs/__files/body-users-fussybeaver-subscriptions-wv2Q5.json b/core/tests/stubs/__files/body-users-fussybeaver-subscriptions-wv2Q5.json similarity index 100% rename from tests/stubs/__files/body-users-fussybeaver-subscriptions-wv2Q5.json rename to core/tests/stubs/__files/body-users-fussybeaver-subscriptions-wv2Q5.json diff --git a/tests/stubs/__files/body-users-tXACn.json b/core/tests/stubs/__files/body-users-tXACn.json similarity index 100% rename from tests/stubs/__files/body-users-tXACn.json rename to core/tests/stubs/__files/body-users-tXACn.json diff --git a/tests/stubs/mappings/mapping-gists-public-jAiWv.json b/core/tests/stubs/mappings/mapping-gists-public-jAiWv.json similarity index 100% rename from tests/stubs/mappings/mapping-gists-public-jAiWv.json rename to core/tests/stubs/mappings/mapping-gists-public-jAiWv.json diff --git a/tests/stubs/mappings/mapping-licenses-MMedz.json b/core/tests/stubs/mappings/mapping-licenses-MMedz.json similarity index 100% rename from tests/stubs/mappings/mapping-licenses-MMedz.json rename to core/tests/stubs/mappings/mapping-licenses-MMedz.json diff --git a/tests/stubs/mappings/mapping-licenses-unlicense-7CKkm.json b/core/tests/stubs/mappings/mapping-licenses-unlicense-7CKkm.json similarity index 100% rename from tests/stubs/mappings/mapping-licenses-unlicense-7CKkm.json rename to core/tests/stubs/mappings/mapping-licenses-unlicense-7CKkm.json diff --git a/tests/stubs/mappings/mapping-meta-UpvZy.json b/core/tests/stubs/mappings/mapping-meta-UpvZy.json similarity index 100% rename from tests/stubs/mappings/mapping-meta-UpvZy.json rename to core/tests/stubs/mappings/mapping-meta-UpvZy.json diff --git a/tests/stubs/mappings/mapping-rate_limit-WEcsT.json b/core/tests/stubs/mappings/mapping-rate_limit-WEcsT.json similarity index 100% rename from tests/stubs/mappings/mapping-rate_limit-WEcsT.json rename to core/tests/stubs/mappings/mapping-rate_limit-WEcsT.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-branches-master-protection-restrictions-users-9ARKG.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-MzcU8.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-MzcU8.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-MzcU8.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-MzcU8.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-XlXSM.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-XlXSM.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-XlXSM.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-commits-XlXSM.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-events-GsS4J.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-events-GsS4J.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-events-GsS4J.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-events-GsS4J.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-68wNX.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-68wNX.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-68wNX.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-68wNX.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-86-reactions-v1oBT.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-comments-2RXrT.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-comments-2RXrT.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-comments-2RXrT.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-comments-2RXrT.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-events-JDYdG.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-events-JDYdG.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-events-JDYdG.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-issues-events-JDYdG.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-labels-157cI.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-labels-157cI.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-labels-157cI.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-labels-157cI.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-license-DMLLq.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-license-DMLLq.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-license-DMLLq.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-license-DMLLq.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-milestones-5fuAv.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-milestones-5fuAv.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-milestones-5fuAv.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-milestones-5fuAv.json diff --git a/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-subscribers-lmpNw.json b/core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-subscribers-lmpNw.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-fussybeaver-bollard-subscribers-lmpNw.json rename to core/tests/stubs/mappings/mapping-repos-fussybeaver-bollard-subscribers-lmpNw.json diff --git a/tests/stubs/mappings/mapping-repos-this-user-does-not-exist-bollard-commits-pHO1B.json b/core/tests/stubs/mappings/mapping-repos-this-user-does-not-exist-bollard-commits-pHO1B.json similarity index 100% rename from tests/stubs/mappings/mapping-repos-this-user-does-not-exist-bollard-commits-pHO1B.json rename to core/tests/stubs/mappings/mapping-repos-this-user-does-not-exist-bollard-commits-pHO1B.json diff --git a/tests/stubs/mappings/mapping-search-repositories-eeDr8.json b/core/tests/stubs/mappings/mapping-search-repositories-eeDr8.json similarity index 100% rename from tests/stubs/mappings/mapping-search-repositories-eeDr8.json rename to core/tests/stubs/mappings/mapping-search-repositories-eeDr8.json diff --git a/tests/stubs/mappings/mapping-users-fussybeaver-gpg_keys-H9I34.json b/core/tests/stubs/mappings/mapping-users-fussybeaver-gpg_keys-H9I34.json similarity index 100% rename from tests/stubs/mappings/mapping-users-fussybeaver-gpg_keys-H9I34.json rename to core/tests/stubs/mappings/mapping-users-fussybeaver-gpg_keys-H9I34.json diff --git a/tests/stubs/mappings/mapping-users-fussybeaver-projects-iSt55.json b/core/tests/stubs/mappings/mapping-users-fussybeaver-projects-iSt55.json similarity index 100% rename from tests/stubs/mappings/mapping-users-fussybeaver-projects-iSt55.json rename to core/tests/stubs/mappings/mapping-users-fussybeaver-projects-iSt55.json diff --git a/tests/stubs/mappings/mapping-users-fussybeaver-starred-tTWDw.json b/core/tests/stubs/mappings/mapping-users-fussybeaver-starred-tTWDw.json similarity index 100% rename from tests/stubs/mappings/mapping-users-fussybeaver-starred-tTWDw.json rename to core/tests/stubs/mappings/mapping-users-fussybeaver-starred-tTWDw.json diff --git a/tests/stubs/mappings/mapping-users-fussybeaver-subscriptions-wv2Q5.json b/core/tests/stubs/mappings/mapping-users-fussybeaver-subscriptions-wv2Q5.json similarity index 100% rename from tests/stubs/mappings/mapping-users-fussybeaver-subscriptions-wv2Q5.json rename to core/tests/stubs/mappings/mapping-users-fussybeaver-subscriptions-wv2Q5.json diff --git a/tests/stubs/mappings/mapping-users-tXACn.json b/core/tests/stubs/mappings/mapping-users-tXACn.json similarity index 100% rename from tests/stubs/mappings/mapping-users-tXACn.json rename to core/tests/stubs/mappings/mapping-users-tXACn.json diff --git a/tests/sync.rs b/core/tests/sync.rs similarity index 95% rename from tests/sync.rs rename to core/tests/sync.rs index ebd2879..81e7ade 100644 --- a/tests/sync.rs +++ b/core/tests/sync.rs @@ -3,14 +3,10 @@ use roctogen::api::{ self, activity, gists, issues, licenses, meta, rate_limit, reactions, repos, search, users, }; -#[cfg(any( - feature = "reqwest", - feature = "ureq", - target_arch = "wasm32" -))] -use roctogen::adapters::client; -use roctogen::auth::Auth; use roctogen::models; +#[cfg(any(feature = "reqwest", feature = "ureq", target_arch = "wasm32"))] +use roctokit::adapters::client; +use roctokit::auth::Auth; use log::{debug, info}; @@ -110,7 +106,6 @@ fn issues_sync_ok() { #[cfg(all(not(target_arch = "wasm32"), not(feature = "reqwest")))] #[test] fn license_sync_ok() { - env_logger::try_init(); use roctogen::api::licenses::LicensesGetForRepoParams; let auth = Auth::None; @@ -118,7 +113,6 @@ fn license_sync_ok() { let license = licenses::new(&client); let req = license.get_for_repo("fussybeaver", "bollard", None::); - debug!("{:?}", req); assert!(req.is_ok()); let req = license.get_all_commonly_used(None::); @@ -201,7 +195,11 @@ fn post_sync_fail() { repos::new(&client).add_user_access_restrictions("fussybeaver", "bollard", "master", body); match &req { Ok(_) => {} - Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + Err(roctokit::adapters::AdapterError::Endpoint { + description, + status_code: 404, + .. + }) => { debug!("{}", description); } Err(_) => { diff --git a/examples/auth/github-update-issue-bot/Cargo.toml b/examples/auth/github-update-issue-bot/Cargo.toml index 4720d88..778aae3 100644 --- a/examples/auth/github-update-issue-bot/Cargo.toml +++ b/examples/auth/github-update-issue-bot/Cargo.toml @@ -1,8 +1,7 @@ [package] name = "roctogen-github-update-issue-bot" version = "0.1.0" -authors = ["Niel Drummond "] -edition = "2018" +edition = "2021" [lib] crate-type = ["cdylib", "rlib"] @@ -19,7 +18,8 @@ console_error_panic_hook = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"] } serde_derive.workspace = true serde_json.workspace = true -roctogen = { version = "*", path = "../../.." } +roctogen.workspace = true +roctokit.workspace = true js-sys.workspace = true log.workspace = true console_log = { workspace = true, features = ["color"] } diff --git a/examples/auth/github-update-issue-bot/src/lib.rs b/examples/auth/github-update-issue-bot/src/lib.rs index 998bd73..b38edaa 100644 --- a/examples/auth/github-update-issue-bot/src/lib.rs +++ b/examples/auth/github-update-issue-bot/src/lib.rs @@ -1,5 +1,4 @@ -extern crate cfg_if; -extern crate wasm_bindgen; +#![cfg(target_arch = "wasm32")] mod utils; @@ -9,10 +8,10 @@ use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use wasm_bindgen_futures::JsFuture; -use roctogen::adapters::{wasm, Client}; use roctogen::api::{self, apps, issues, repos}; -use roctogen::auth::Auth; use roctogen::models; +use roctokit::adapters::{wasm, Client}; +use roctokit::auth::Auth; use log::{debug, info, trace, Level}; diff --git a/examples/auth/wasm-jwt/Cargo.toml b/examples/auth/wasm-jwt/Cargo.toml index 7f6f99e..96a959e 100644 --- a/examples/auth/wasm-jwt/Cargo.toml +++ b/examples/auth/wasm-jwt/Cargo.toml @@ -1,8 +1,7 @@ [package] name = "roctogen-jwt-example" version = "0.1.0" -authors = ["Niel Drummond "] -edition = "2018" +edition = "2021" [lib] crate-type = ["cdylib", "rlib"] @@ -16,7 +15,8 @@ cfg-if.workspace = true wasm-bindgen = { workspace = true, features = ["serde-serialize"] } wasm-bindgen-futures.workspace = true console_error_panic_hook = { workspace = true, optional = true } -roctogen = { version = "*", path = "../../.." } +roctogen.workspace = true +roctokit.workspace = true js-sys.workspace = true log.workspace = true console_log = { workspace = true, features = ["color"] } diff --git a/examples/auth/wasm-jwt/src/lib.rs b/examples/auth/wasm-jwt/src/lib.rs index e340088..742ac36 100644 --- a/examples/auth/wasm-jwt/src/lib.rs +++ b/examples/auth/wasm-jwt/src/lib.rs @@ -1,13 +1,15 @@ +#![cfg(target_arch = "wasm32")] + mod utils; use cfg_if::cfg_if; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; -use roctogen::adapters::{wasm, Client}; use roctogen::api::apps; -use roctogen::auth::Auth; use roctogen::models; +use roctokit::adapters::{wasm, Client}; +use roctokit::auth::Auth; use log::{error, info, Level}; diff --git a/examples/min-req-adapter/Cargo.toml b/examples/min-req-adapter/Cargo.toml index d6df907..52d5a62 100644 --- a/examples/min-req-adapter/Cargo.toml +++ b/examples/min-req-adapter/Cargo.toml @@ -10,4 +10,5 @@ log.workspace = true serde.workspace = true serde_json.workspace = true base64.workspace = true -roctogen = { path = "../../" } +roctogen.workspace = true +roctokit.workspace = true diff --git a/examples/min-req-adapter/src/main.rs b/examples/min-req-adapter/src/main.rs index 127cf12..c49f56a 100644 --- a/examples/min-req-adapter/src/main.rs +++ b/examples/min-req-adapter/src/main.rs @@ -1,9 +1,8 @@ use base64::{prelude::BASE64_STANDARD, Engine}; -use roctogen::adapters::GitHubRequest; -use roctogen::adapters::GitHubResponseExt; -use roctogen::auth::Auth; +use roctokit::adapters::GitHubRequest; +use roctokit::adapters::GitHubResponseExt; +use roctokit::auth::Auth; use serde::{ser, Deserialize}; -use std::error::Error; #[derive(thiserror::Error, Debug)] pub enum AdapterError { @@ -17,7 +16,7 @@ pub enum AdapterError { UnimplementedAsync, } -impl From for roctogen::adapters::AdapterError { +impl From for roctokit::adapters::AdapterError { fn from(err: AdapterError) -> Self { Self::Client { description: err.to_string(), @@ -30,9 +29,12 @@ struct Response { pub inner: minreq::Response, } -impl roctogen::adapters::Client for Client { +impl roctokit::adapters::Client for Client { type Req = minreq::Request; - type Err = AdapterError where roctogen::adapters::AdapterError: From; + type Err + = AdapterError + where + roctokit::adapters::AdapterError: From; type Body = Vec; fn new(auth: &Auth) -> Result { @@ -53,7 +55,7 @@ impl roctogen::adapters::Client for Client { let mut min_req = minreq::Request::new(minreq::Method::Custom(String::from(req.method)), req.uri); min_req = min_req.with_header("accept", "application/vnd.github.v3+json"); - min_req = min_req.with_header("user-agent", "roctogen"); + min_req = min_req.with_header("user-agent", "roctokit"); min_req = min_req.with_header("content-type", "application/json"); for header in req.headers.iter() { diff --git a/examples/search/Cargo.toml b/examples/search/Cargo.toml index 055d92d..8637a82 100644 --- a/examples/search/Cargo.toml +++ b/examples/search/Cargo.toml @@ -14,9 +14,10 @@ hyper-rustls = "0.27" http-body-util = "0.1" rustls = "0.23" tokio = { version = "1", features = ["rt-multi-thread", "macros"] } -thiserror.workspace = true -log.workspace = true -serde.workspace = true -serde_json.workspace = true -base64.workspace = true -roctogen = { path = "../../" } +thiserror = "1" +log = "0.4" +serde = "1.0" +serde_json = {version = "1.0"} +base64 = "0.22" +roctogen = { path = "../../roctogen" } +roctokit = { path = "../../core" } diff --git a/examples/search/src/main.rs b/examples/search/src/main.rs index ac13a0a..2fc5d2b 100644 --- a/examples/search/src/main.rs +++ b/examples/search/src/main.rs @@ -22,11 +22,11 @@ use hyper::header::USER_AGENT; use hyper_rustls::ConfigBuilderExt; use hyper_util::client::legacy::connect::HttpConnector; use log::debug; -use roctogen::adapters::GitHubRequest; -use roctogen::adapters::GitHubResponseExt; use roctogen::api::search; use roctogen::api::PerPage; -use roctogen::auth::Auth; +use roctokit::adapters::GitHubRequest; +use roctokit::adapters::GitHubResponseExt; +use roctokit::auth::Auth; use serde::de::Error; use serde::{ser, Deserialize}; @@ -54,7 +54,7 @@ pub enum AdapterError { ParseIntError(#[from] std::num::ParseIntError), } -impl From for roctogen::adapters::AdapterError { +impl From for roctokit::adapters::AdapterError { fn from(err: AdapterError) -> Self { Self::Client { description: err.to_string(), @@ -67,9 +67,12 @@ struct Response { pub inner: hyper::Response, } -impl roctogen::adapters::Client for Client { +impl roctokit::adapters::Client for Client { type Req = hyper::Request>; - type Err = AdapterError where roctogen::adapters::AdapterError: From; + type Err + = AdapterError + where + roctokit::adapters::AdapterError: From; type Body = Empty; fn new(auth: &Auth) -> Result { @@ -131,7 +134,7 @@ impl roctogen::adapters::Client for Client { .uri(req.uri) .method(req.method) .header(ACCEPT, "application/vnd.github.v3+json") - .header(USER_AGENT, "roctogen") + .header(USER_AGENT, "roctokit") .header(CONTENT_TYPE, "application/json"); for header in req.headers.iter() { @@ -209,7 +212,7 @@ struct IterableState { #[tokio::main] async fn main() -> Result<(), Box> { - let client: Client = ::new(&Auth::None).unwrap(); + let client: Client = ::new(&Auth::None).unwrap(); let per_page = roctogen::api::PerPage::new(100); let search = roctogen::api::search::new(&client); let stream = unfold(&search, per_page.as_ref()); @@ -225,7 +228,7 @@ fn unfold<'a>( search: &'a search::Search, per_page: &'a PerPage, ) -> impl stream::Stream< - Item = Result, + Item = Result, > + 'a { let state = IterableState { page: 1, diff --git a/pom.xml b/pom.xml index e376dfc..74eb53d 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json github.GitHubCodegen - ${project.basedir} + ${project.basedir}/roctogen true ${project.basedir}/codegen/templates diff --git a/roctogen/Cargo.toml b/roctogen/Cargo.toml new file mode 100644 index 0000000..0ee9c9a --- /dev/null +++ b/roctogen/Cargo.toml @@ -0,0 +1,88 @@ +[package] +name = "roctogen" +version = "0.13.0" +authors = [ "Roctogen contributors" ] +description = "Github API and models generated from the official swagger OpenAPI specification" +license = "Apache-2.0" +homepage = "https://github.com/fussybeaver/roctokit" +repository = "https://github.com/fussybeaver/roctokit" +documentation = "https://docs.rs/roctogen" +readme = "README.md" +keywords = ["github"] +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] +path = "src/lib.rs" + +[features] +default = [] +reqwest = ["dep:reqwest", "dep:bytes"] + +# Activate mock base url +mock = [] + +[dependencies] +base64 = "0.22" +chrono = { version = "0.4", features = ["serde"] } +http = "1.1" +serde = "1.0" +serde_derive = "1.0" +serde_json = {version = "1.0"} +serde_urlencoded = { version = "0.7" } +thiserror = "1" +log = "0.4" +roctokit = { workspace = true } + +# wasm +cfg-if = { version = "1" } +wasm-bindgen = { version = "0.2.95", features = ["serde-serialize"] } +wasm-bindgen-futures = { version = "0.4" } +console_error_panic_hook = { version = "0.1.1" } +wee_alloc = { version = "0.4.2" } +js-sys = { version = "0.3" } +web-sys = { version = "0.3", features = [ 'Headers', 'Request', 'RequestInit', 'Response', 'ServiceWorkerGlobalScope', 'Window', 'console' ] } +console_log = { version = "1", features = ["color"] } + +bytes = { version = "1", optional = true } + +# reqwest +reqwest = { version = "0.12", optional = true, features = [] } + +# ureq +ureq = { version = "3.0.3", optional = true, features = ["json"] } + +# wasm +[target.'cfg(target_arch = "wasm32")'.dependencies] +cfg-if = { version = "1" } +wasm-bindgen = { version = "0.2.95", features = ["serde-serialize"] } +wasm-bindgen-futures = { version = "0.4" } +console_error_panic_hook = { version = "0.1.1" } +wee_alloc = { version = "0.4.2" } +js-sys = { version = "0.3" } + +[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys] +version = "0.3" +features = [ + 'Headers', + 'Request', + 'RequestInit', + 'Response', + 'ServiceWorkerGlobalScope', + 'Window', + 'console', +] + +[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +wasm-bindgen-test = "0.3.45" + +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +futures-lite = { version = "2.3" } +futures-io = { version = "0.3" } +futures-core = { version = "0.3" } +tokio = { version = "1.2", default-features = false, features = ["macros", "rt-multi-thread"] } +env_logger = "0.11" + +[package.metadata.docs.rs] +default-target = "x86_64-unknown-linux-gnu" +targets = ["wasm32-unknown-unknown"] diff --git a/roctogen/README.md b/roctogen/README.md new file mode 100644 index 0000000..7105725 --- /dev/null +++ b/roctogen/README.md @@ -0,0 +1,94 @@ +[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![docs](https://docs.rs/roctogen/badge.svg)](https://docs.rs/roctogen/) +[![GitHub workflow](https://github.com/fussybeaver/roctogen/actions/workflows/default.yml/badge.svg)](https://github.com/fussybeaver/roctogen/actions/workflows/default.yml) + +## Roctogen: Rust Client Library for GitHub v3 API + +**Roctogen** is a Rust library generated from the [GitHub REST API OpenAPI +specification](https://github.com/github/rest-api-description/). providing +comprehensive support for the GitHub v3 API. It provides generated models +and endpoints that are intended to be used with the sister library +[**roctokit**](../roctokit/README.md), that provides client interfaces. + +### Documentation + +- [API docs](https://docs.rs/roctogen/latest). +- [Endpoints](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html). + +#### Supported endpoints: + +Roctogen supports a wide range of GitHub API endpoints, including: + + - [Meta](https://docs.rs/roctogen/latest/roctogen/endpoints/meta/struct.Meta.html) + - [Issues](https://docs.rs/roctogen/latest/roctogen/endpoints/issues/struct.Issues.html) + - [Licenses](https://docs.rs/roctogen/latest/roctogen/endpoints/licenses/struct.Licenses.html) + - [Reactions](https://docs.rs/roctogen/latest/roctogen/endpoints/reactions/struct.Reactions.html) + - [Activity](https://docs.rs/roctogen/latest/roctogen/endpoints/activity/struct.Activity.html) + - [Projects](https://docs.rs/roctogen/latest/roctogen/endpoints/projects/struct.Projects.html) + - [Orgs](https://docs.rs/roctogen/latest/roctogen/endpoints/orgs/struct.Orgs.html) + - [Users](https://docs.rs/roctogen/latest/roctogen/endpoints/users/struct.Users.html) + - [Apps](https://docs.rs/roctogen/latest/roctogen/endpoints/apps/struct.Apps.html) + - [RateLimit](https://docs.rs/roctogen/latest/roctogen/endpoints/rate_limit/struct.RateLimit.html) + - [Repos](https://docs.rs/roctogen/latest/roctogen/endpoints/repos/struct.Repos.html) + - [SecretScanning](https://docs.rs/roctogen/latest/roctogen/endpoints/secret_scanning/struct.SecretScanning.html) + - [SecurityAdvisories](https://docs.rs/roctogen/latest/roctogen/endpoints/security_advisories/struct.SecurityAdvisories.html) + - [Packages](https://docs.rs/roctogen/latest/roctogen/endpoints/packages/struct.Packages.html) + - [Search](https://docs.rs/roctogen/latest/roctogen/endpoints/search/struct.Search.html) + - [Classroom](https://docs.rs/roctogen/latest/roctogen/endpoints/classroom/struct.Classroom.html) + - [Teams](https://docs.rs/roctogen/latest/roctogen/endpoints/teams/struct.Teams.html) + - [PrivateRegistries](https://docs.rs/roctogen/latest/roctogen/endpoints/private_registries/struct.PrivateRegistries.html) + - [Oidc](https://docs.rs/roctogen/latest/roctogen/endpoints/oidc/struct.Oidc.html) + - [Markdown](https://docs.rs/roctogen/latest/roctogen/endpoints/markdown/struct.Markdown.html) + - [Actions](https://docs.rs/roctogen/latest/roctogen/endpoints/actions/struct.Actions.html) + - [Migrations](https://docs.rs/roctogen/latest/roctogen/endpoints/migrations/struct.Migrations.html) + - [CodeSecurity](https://docs.rs/roctogen/latest/roctogen/endpoints/code_security/struct.CodeSecurity.html) + - [Gists](https://docs.rs/roctogen/latest/roctogen/endpoints/gists/struct.Gists.html) + - [HostedCompute](https://docs.rs/roctogen/latest/roctogen/endpoints/hosted_compute/struct.HostedCompute.html) + - [DependencyGraph](https://docs.rs/roctogen/latest/roctogen/endpoints/dependency_graph/struct.DependencyGraph.html) + - [Copilot](https://docs.rs/roctogen/latest/roctogen/endpoints/copilot/struct.Copilot.html) + - [Dependabot](https://docs.rs/roctogen/latest/roctogen/endpoints/dependabot/struct.Dependabot.html) + - [CodesOfConduct](https://docs.rs/roctogen/latest/roctogen/endpoints/codes_of_conduct/struct.CodesOfConduct.html) + - [Pulls](https://docs.rs/roctogen/latest/roctogen/endpoints/pulls/struct.Pulls.html) + - [Gitignore](https://docs.rs/roctogen/latest/roctogen/endpoints/gitignore/struct.Gitignore.html) + - [Git](https://docs.rs/roctogen/latest/roctogen/endpoints/git/struct.Git.html) + - [CodeScanning](https://docs.rs/roctogen/latest/roctogen/endpoints/code_scanning/struct.CodeScanning.html) + - [Checks](https://docs.rs/roctogen/latest/roctogen/endpoints/checks/struct.Checks.html) + - [Billing](https://docs.rs/roctogen/latest/roctogen/endpoints/billing/struct.Billing.html) + - [Interactions](https://docs.rs/roctogen/latest/roctogen/endpoints/interactions/struct.Interactions.html) + - [Codespaces](https://docs.rs/roctogen/latest/roctogen/endpoints/codespaces/struct.Codespaces.html) + - [Emojis](https://docs.rs/roctogen/latest/roctogen/endpoints/emojis/struct.Emojis.html) + +For a full list of supported endpoints, refer to the [API documentation](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html). + +### Usage + +Here's a basic example demonstrating how to use Roctogen: + +```rust +use roctogen::api::{self, repos}; +use roctokit::adapters::client; +use roctokit::auth::Auth; + +let auth = Auth::None; +let client = client(&auth).expect("Cannot create new client"); +let per_page = api::PerPage::new(10); + +let mut params: repos::ReposListCommitsParams = per_page.as_ref().into(); +params = params.author("fussybeaver").page(2); + +repos::new(&client).list_commits("fussybeaver", "bollard", Some(params)); +``` + +### Generating the API + +Roctogen's code is largely generated from the GitHub REST API specification +using the [Swagger OpenAPI +generator](https://github.com/swagger-api/swagger-codegen) (version 3). +Building the API requires the Java-based `mvn` tool with JDK 8 installed: + +```nocompile +$ mvn -D org.slf4j.simpleLogger.defaultLogLevel=info clean compiler:compile generate-resources +``` + + +License: Apache-2.0 diff --git a/src/endpoints/actions.rs b/roctogen/src/endpoints/actions.rs similarity index 99% rename from src/endpoints/actions.rs rename to roctogen/src/endpoints/actions.rs index f840e02..f92a5ed 100644 --- a/src/endpoints/actions.rs +++ b/roctogen/src/endpoints/actions.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/activity.rs b/roctogen/src/endpoints/activity.rs similarity index 99% rename from src/endpoints/activity.rs rename to roctogen/src/endpoints/activity.rs index 24dd4f0..1106778 100644 --- a/src/endpoints/activity.rs +++ b/roctogen/src/endpoints/activity.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/apps.rs b/roctogen/src/endpoints/apps.rs similarity index 99% rename from src/endpoints/apps.rs rename to roctogen/src/endpoints/apps.rs index 6d08fe6..8d40e56 100644 --- a/src/endpoints/apps.rs +++ b/roctogen/src/endpoints/apps.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/billing.rs b/roctogen/src/endpoints/billing.rs similarity index 99% rename from src/endpoints/billing.rs rename to roctogen/src/endpoints/billing.rs index 7657f24..62703b7 100644 --- a/src/endpoints/billing.rs +++ b/roctogen/src/endpoints/billing.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/checks.rs b/roctogen/src/endpoints/checks.rs similarity index 99% rename from src/endpoints/checks.rs rename to roctogen/src/endpoints/checks.rs index a328b37..54ac1a4 100644 --- a/src/endpoints/checks.rs +++ b/roctogen/src/endpoints/checks.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/classroom.rs b/roctogen/src/endpoints/classroom.rs similarity index 99% rename from src/endpoints/classroom.rs rename to roctogen/src/endpoints/classroom.rs index 2ee6a82..eb43c76 100644 --- a/src/endpoints/classroom.rs +++ b/roctogen/src/endpoints/classroom.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/code_scanning.rs b/roctogen/src/endpoints/code_scanning.rs similarity index 99% rename from src/endpoints/code_scanning.rs rename to roctogen/src/endpoints/code_scanning.rs index f4b23a6..4ec9399 100644 --- a/src/endpoints/code_scanning.rs +++ b/roctogen/src/endpoints/code_scanning.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/code_security.rs b/roctogen/src/endpoints/code_security.rs similarity index 99% rename from src/endpoints/code_security.rs rename to roctogen/src/endpoints/code_security.rs index c9a192c..c09b808 100644 --- a/src/endpoints/code_security.rs +++ b/roctogen/src/endpoints/code_security.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/codes_of_conduct.rs b/roctogen/src/endpoints/codes_of_conduct.rs similarity index 98% rename from src/endpoints/codes_of_conduct.rs rename to roctogen/src/endpoints/codes_of_conduct.rs index f1f1c4c..ca266dc 100644 --- a/src/endpoints/codes_of_conduct.rs +++ b/roctogen/src/endpoints/codes_of_conduct.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/codespaces.rs b/roctogen/src/endpoints/codespaces.rs similarity index 99% rename from src/endpoints/codespaces.rs rename to roctogen/src/endpoints/codespaces.rs index 471579b..131e446 100644 --- a/src/endpoints/codespaces.rs +++ b/roctogen/src/endpoints/codespaces.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/copilot.rs b/roctogen/src/endpoints/copilot.rs similarity index 99% rename from src/endpoints/copilot.rs rename to roctogen/src/endpoints/copilot.rs index bc31cd8..e452bfb 100644 --- a/src/endpoints/copilot.rs +++ b/roctogen/src/endpoints/copilot.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/dependabot.rs b/roctogen/src/endpoints/dependabot.rs similarity index 99% rename from src/endpoints/dependabot.rs rename to roctogen/src/endpoints/dependabot.rs index 691136c..91823c1 100644 --- a/src/endpoints/dependabot.rs +++ b/roctogen/src/endpoints/dependabot.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/dependency_graph.rs b/roctogen/src/endpoints/dependency_graph.rs similarity index 99% rename from src/endpoints/dependency_graph.rs rename to roctogen/src/endpoints/dependency_graph.rs index 6a4c251..b80a15b 100644 --- a/src/endpoints/dependency_graph.rs +++ b/roctogen/src/endpoints/dependency_graph.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/emojis.rs b/roctogen/src/endpoints/emojis.rs similarity index 97% rename from src/endpoints/emojis.rs rename to roctogen/src/endpoints/emojis.rs index a8c6103..b6a993e 100644 --- a/src/endpoints/emojis.rs +++ b/roctogen/src/endpoints/emojis.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/gists.rs b/roctogen/src/endpoints/gists.rs similarity index 99% rename from src/endpoints/gists.rs rename to roctogen/src/endpoints/gists.rs index 32f387f..08858bf 100644 --- a/src/endpoints/gists.rs +++ b/roctogen/src/endpoints/gists.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/git.rs b/roctogen/src/endpoints/git.rs similarity index 99% rename from src/endpoints/git.rs rename to roctogen/src/endpoints/git.rs index 3c798a7..300aad6 100644 --- a/src/endpoints/git.rs +++ b/roctogen/src/endpoints/git.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/gitignore.rs b/roctogen/src/endpoints/gitignore.rs similarity index 98% rename from src/endpoints/gitignore.rs rename to roctogen/src/endpoints/gitignore.rs index 12daa61..b73abee 100644 --- a/src/endpoints/gitignore.rs +++ b/roctogen/src/endpoints/gitignore.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/hosted_compute.rs b/roctogen/src/endpoints/hosted_compute.rs similarity index 99% rename from src/endpoints/hosted_compute.rs rename to roctogen/src/endpoints/hosted_compute.rs index 9292bfd..06a9f47 100644 --- a/src/endpoints/hosted_compute.rs +++ b/roctogen/src/endpoints/hosted_compute.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/interactions.rs b/roctogen/src/endpoints/interactions.rs similarity index 99% rename from src/endpoints/interactions.rs rename to roctogen/src/endpoints/interactions.rs index 53166db..75abdd1 100644 --- a/src/endpoints/interactions.rs +++ b/roctogen/src/endpoints/interactions.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/issues.rs b/roctogen/src/endpoints/issues.rs similarity index 99% rename from src/endpoints/issues.rs rename to roctogen/src/endpoints/issues.rs index a4c8d79..f58f7f9 100644 --- a/src/endpoints/issues.rs +++ b/roctogen/src/endpoints/issues.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/licenses.rs b/roctogen/src/endpoints/licenses.rs similarity index 99% rename from src/endpoints/licenses.rs rename to roctogen/src/endpoints/licenses.rs index c212c95..b0f59dc 100644 --- a/src/endpoints/licenses.rs +++ b/roctogen/src/endpoints/licenses.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/markdown.rs b/roctogen/src/endpoints/markdown.rs similarity index 98% rename from src/endpoints/markdown.rs rename to roctogen/src/endpoints/markdown.rs index 066f074..ea79cae 100644 --- a/src/endpoints/markdown.rs +++ b/roctogen/src/endpoints/markdown.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/meta.rs b/roctogen/src/endpoints/meta.rs similarity index 99% rename from src/endpoints/meta.rs rename to roctogen/src/endpoints/meta.rs index 9a29e11..53a34c6 100644 --- a/src/endpoints/meta.rs +++ b/roctogen/src/endpoints/meta.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/migrations.rs b/roctogen/src/endpoints/migrations.rs similarity index 99% rename from src/endpoints/migrations.rs rename to roctogen/src/endpoints/migrations.rs index 9a6e980..c5ce458 100644 --- a/src/endpoints/migrations.rs +++ b/roctogen/src/endpoints/migrations.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/mod.rs b/roctogen/src/endpoints/mod.rs similarity index 100% rename from src/endpoints/mod.rs rename to roctogen/src/endpoints/mod.rs diff --git a/src/endpoints/oidc.rs b/roctogen/src/endpoints/oidc.rs similarity index 99% rename from src/endpoints/oidc.rs rename to roctogen/src/endpoints/oidc.rs index 1d20226..3ed28fb 100644 --- a/src/endpoints/oidc.rs +++ b/roctogen/src/endpoints/oidc.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/orgs.rs b/roctogen/src/endpoints/orgs.rs similarity index 99% rename from src/endpoints/orgs.rs rename to roctogen/src/endpoints/orgs.rs index f39a2f2..338d3eb 100644 --- a/src/endpoints/orgs.rs +++ b/roctogen/src/endpoints/orgs.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/packages.rs b/roctogen/src/endpoints/packages.rs similarity index 99% rename from src/endpoints/packages.rs rename to roctogen/src/endpoints/packages.rs index 0954311..817752e 100644 --- a/src/endpoints/packages.rs +++ b/roctogen/src/endpoints/packages.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/private_registries.rs b/roctogen/src/endpoints/private_registries.rs similarity index 99% rename from src/endpoints/private_registries.rs rename to roctogen/src/endpoints/private_registries.rs index 856f7be..b991ff6 100644 --- a/src/endpoints/private_registries.rs +++ b/roctogen/src/endpoints/private_registries.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/projects.rs b/roctogen/src/endpoints/projects.rs similarity index 99% rename from src/endpoints/projects.rs rename to roctogen/src/endpoints/projects.rs index ba5fa6a..8713323 100644 --- a/src/endpoints/projects.rs +++ b/roctogen/src/endpoints/projects.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/pulls.rs b/roctogen/src/endpoints/pulls.rs similarity index 99% rename from src/endpoints/pulls.rs rename to roctogen/src/endpoints/pulls.rs index 188f157..cd2f374 100644 --- a/src/endpoints/pulls.rs +++ b/roctogen/src/endpoints/pulls.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/rate_limit.rs b/roctogen/src/endpoints/rate_limit.rs similarity index 99% rename from src/endpoints/rate_limit.rs rename to roctogen/src/endpoints/rate_limit.rs index d9668d5..b9a050a 100644 --- a/src/endpoints/rate_limit.rs +++ b/roctogen/src/endpoints/rate_limit.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/reactions.rs b/roctogen/src/endpoints/reactions.rs similarity index 99% rename from src/endpoints/reactions.rs rename to roctogen/src/endpoints/reactions.rs index b907880..af4ca11 100644 --- a/src/endpoints/reactions.rs +++ b/roctogen/src/endpoints/reactions.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/repos.rs b/roctogen/src/endpoints/repos.rs similarity index 99% rename from src/endpoints/repos.rs rename to roctogen/src/endpoints/repos.rs index 35bf0e1..6d3c359 100644 --- a/src/endpoints/repos.rs +++ b/roctogen/src/endpoints/repos.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/search.rs b/roctogen/src/endpoints/search.rs similarity index 99% rename from src/endpoints/search.rs rename to roctogen/src/endpoints/search.rs index a2122d9..7504779 100644 --- a/src/endpoints/search.rs +++ b/roctogen/src/endpoints/search.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/secret_scanning.rs b/roctogen/src/endpoints/secret_scanning.rs similarity index 99% rename from src/endpoints/secret_scanning.rs rename to roctogen/src/endpoints/secret_scanning.rs index 7a8cab1..fbaf144 100644 --- a/src/endpoints/secret_scanning.rs +++ b/roctogen/src/endpoints/secret_scanning.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/security_advisories.rs b/roctogen/src/endpoints/security_advisories.rs similarity index 99% rename from src/endpoints/security_advisories.rs rename to roctogen/src/endpoints/security_advisories.rs index fe708ad..daa20c5 100644 --- a/src/endpoints/security_advisories.rs +++ b/roctogen/src/endpoints/security_advisories.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/teams.rs b/roctogen/src/endpoints/teams.rs similarity index 99% rename from src/endpoints/teams.rs rename to roctogen/src/endpoints/teams.rs index 7795562..901a3b1 100644 --- a/src/endpoints/teams.rs +++ b/roctogen/src/endpoints/teams.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/src/endpoints/users.rs b/roctogen/src/endpoints/users.rs similarity index 99% rename from src/endpoints/users.rs rename to roctogen/src/endpoints/users.rs index e553c2e..3ac5da5 100644 --- a/src/endpoints/users.rs +++ b/roctogen/src/endpoints/users.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; +use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; diff --git a/roctogen/src/lib.rs b/roctogen/src/lib.rs new file mode 100644 index 0000000..c369306 --- /dev/null +++ b/roctogen/src/lib.rs @@ -0,0 +1,120 @@ +//! [![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +//! [![docs](https://docs.rs/roctogen/badge.svg)](https://docs.rs/roctogen/) +//! [![GitHub workflow](https://github.com/fussybeaver/roctogen/actions/workflows/default.yml/badge.svg)](https://github.com/fussybeaver/roctogen/actions/workflows/default.yml) +//! +//! # Roctogen: Rust Client Library for GitHub v3 API +//! +//! **Roctogen** is a Rust library generated from the [GitHub REST API OpenAPI +//! specification](https://github.com/github/rest-api-description/). providing +//! comprehensive support for the GitHub v3 API. It provides generated models +//! and endpoints that are intended to be used with the sister library +//! [**roctokit**](../roctokit/README.md), that provides client interfaces. +//! +//! ## Documentation +//! +//! - [API docs](https://docs.rs/roctogen/latest). +//! - [Endpoints](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html). +//! +//! ### Supported endpoints: +//! +//! Roctogen supports a wide range of GitHub API endpoints, including: +//! +//! - [Meta](https://docs.rs/roctogen/latest/roctogen/endpoints/meta/struct.Meta.html) +//! - [Issues](https://docs.rs/roctogen/latest/roctogen/endpoints/issues/struct.Issues.html) +//! - [Licenses](https://docs.rs/roctogen/latest/roctogen/endpoints/licenses/struct.Licenses.html) +//! - [Reactions](https://docs.rs/roctogen/latest/roctogen/endpoints/reactions/struct.Reactions.html) +//! - [Activity](https://docs.rs/roctogen/latest/roctogen/endpoints/activity/struct.Activity.html) +//! - [Projects](https://docs.rs/roctogen/latest/roctogen/endpoints/projects/struct.Projects.html) +//! - [Orgs](https://docs.rs/roctogen/latest/roctogen/endpoints/orgs/struct.Orgs.html) +//! - [Users](https://docs.rs/roctogen/latest/roctogen/endpoints/users/struct.Users.html) +//! - [Apps](https://docs.rs/roctogen/latest/roctogen/endpoints/apps/struct.Apps.html) +//! - [RateLimit](https://docs.rs/roctogen/latest/roctogen/endpoints/rate_limit/struct.RateLimit.html) +//! - [Repos](https://docs.rs/roctogen/latest/roctogen/endpoints/repos/struct.Repos.html) +//! - [SecretScanning](https://docs.rs/roctogen/latest/roctogen/endpoints/secret_scanning/struct.SecretScanning.html) +//! - [SecurityAdvisories](https://docs.rs/roctogen/latest/roctogen/endpoints/security_advisories/struct.SecurityAdvisories.html) +//! - [Packages](https://docs.rs/roctogen/latest/roctogen/endpoints/packages/struct.Packages.html) +//! - [Search](https://docs.rs/roctogen/latest/roctogen/endpoints/search/struct.Search.html) +//! - [Classroom](https://docs.rs/roctogen/latest/roctogen/endpoints/classroom/struct.Classroom.html) +//! - [Teams](https://docs.rs/roctogen/latest/roctogen/endpoints/teams/struct.Teams.html) +//! - [PrivateRegistries](https://docs.rs/roctogen/latest/roctogen/endpoints/private_registries/struct.PrivateRegistries.html) +//! - [Oidc](https://docs.rs/roctogen/latest/roctogen/endpoints/oidc/struct.Oidc.html) +//! - [Markdown](https://docs.rs/roctogen/latest/roctogen/endpoints/markdown/struct.Markdown.html) +//! - [Actions](https://docs.rs/roctogen/latest/roctogen/endpoints/actions/struct.Actions.html) +//! - [Migrations](https://docs.rs/roctogen/latest/roctogen/endpoints/migrations/struct.Migrations.html) +//! - [CodeSecurity](https://docs.rs/roctogen/latest/roctogen/endpoints/code_security/struct.CodeSecurity.html) +//! - [Gists](https://docs.rs/roctogen/latest/roctogen/endpoints/gists/struct.Gists.html) +//! - [HostedCompute](https://docs.rs/roctogen/latest/roctogen/endpoints/hosted_compute/struct.HostedCompute.html) +//! - [DependencyGraph](https://docs.rs/roctogen/latest/roctogen/endpoints/dependency_graph/struct.DependencyGraph.html) +//! - [Copilot](https://docs.rs/roctogen/latest/roctogen/endpoints/copilot/struct.Copilot.html) +//! - [Dependabot](https://docs.rs/roctogen/latest/roctogen/endpoints/dependabot/struct.Dependabot.html) +//! - [CodesOfConduct](https://docs.rs/roctogen/latest/roctogen/endpoints/codes_of_conduct/struct.CodesOfConduct.html) +//! - [Pulls](https://docs.rs/roctogen/latest/roctogen/endpoints/pulls/struct.Pulls.html) +//! - [Gitignore](https://docs.rs/roctogen/latest/roctogen/endpoints/gitignore/struct.Gitignore.html) +//! - [Git](https://docs.rs/roctogen/latest/roctogen/endpoints/git/struct.Git.html) +//! - [CodeScanning](https://docs.rs/roctogen/latest/roctogen/endpoints/code_scanning/struct.CodeScanning.html) +//! - [Checks](https://docs.rs/roctogen/latest/roctogen/endpoints/checks/struct.Checks.html) +//! - [Billing](https://docs.rs/roctogen/latest/roctogen/endpoints/billing/struct.Billing.html) +//! - [Interactions](https://docs.rs/roctogen/latest/roctogen/endpoints/interactions/struct.Interactions.html) +//! - [Codespaces](https://docs.rs/roctogen/latest/roctogen/endpoints/codespaces/struct.Codespaces.html) +//! - [Emojis](https://docs.rs/roctogen/latest/roctogen/endpoints/emojis/struct.Emojis.html) +//! +//! For a full list of supported endpoints, refer to the [API documentation](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html). +//! +//! ## Usage +//! +//! Here's a basic example demonstrating how to use Roctogen: +//! +//! ```no_run +//! use roctogen::api::{self, repos}; +//! use roctokit::adapters::client; +//! use roctokit::auth::Auth; +//! +//! let auth = Auth::None; +//! let client = client(&auth).expect("Cannot create new client"); +//! let per_page = api::PerPage::new(10); +//! +//! let mut params: repos::ReposListCommitsParams = per_page.as_ref().into(); +//! params = params.author("fussybeaver").page(2); +//! +//! repos::new(&client).list_commits("fussybeaver", "bollard", Some(params)); +//! ``` +//! +//! ## Generating the API +//! +//! Roctogen's code is largely generated from the GitHub REST API specification +//! using the [Swagger OpenAPI +//! generator](https://github.com/swagger-api/swagger-codegen) (version 3). +//! Building the API requires the Java-based `mvn` tool with JDK 8 installed: +//! +//! ```nocompile +//! $ mvn -D org.slf4j.simpleLogger.defaultLogLevel=info clean compiler:compile generate-resources +//! ``` +//! +#![allow( + missing_docs, + unused_imports, +)] + +#[macro_use] +extern crate serde_derive; + +use std::collections::HashMap; + +pub mod endpoints; +pub mod models; + +pub mod auth { + + #[derive(Clone, Debug)] + pub enum Auth { + Basic { + user: String, + pass: String, + }, + Token(String), + Bearer(String), + None, + } +} + +pub use endpoints as api; diff --git a/src/models.rs b/roctogen/src/models.rs similarity index 100% rename from src/models.rs rename to roctogen/src/models.rs