commit ba793acbe34a8ecbecd8df0f67318c8dabd34cb2 Author: Erik Hollensbe Date: Wed Jul 28 14:06:43 2021 -0700 Initial crates moved from https://github.com/zerotier/zeronsd Signed-off-by: Erik Hollensbe diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0825b0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,26 @@ +Copyright 2021 ZeroTier, Inc. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ae77d6f --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +generate: central service + +central: + bash generate.sh central zerotier-central-api + +service: + bash generate.sh service zerotier-one-api + +.PHONY: generate central service diff --git a/generate.sh b/generate.sh new file mode 100644 index 0000000..4a77a25 --- /dev/null +++ b/generate.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -x -euo pipefail + +if [ "x$1" = "x" ] +then + echo "Please read this script before executing it" + exit 1 +fi + +PACKAGE=$1 +PREFIX=$2 + +HOST=${HOST:-docs.zerotier.com} + +rm -rf ./${PREFIX} +mkdir -p ./${PREFIX} +docker pull openapitools/openapi-generator-cli:latest +docker run --rm -u $(id -u):$(id -g) -v ${PWD}/${PREFIX}:/swagger openapitools/openapi-generator-cli generate \ + --package-name ${PREFIX} \ + -i http://${HOST}/openapi/${PACKAGE}v1.json \ + -g rust \ + -o /swagger + +grep -v default-features ${PREFIX}/Cargo.toml > tmp && mv tmp ${PREFIX}/Cargo.toml diff --git a/zerotier-central-api/.gitignore b/zerotier-central-api/.gitignore new file mode 100644 index 0000000..6aa1064 --- /dev/null +++ b/zerotier-central-api/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/zerotier-central-api/.openapi-generator-ignore b/zerotier-central-api/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/zerotier-central-api/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/zerotier-central-api/.openapi-generator/FILES b/zerotier-central-api/.openapi-generator/FILES new file mode 100644 index 0000000..d74c94a --- /dev/null +++ b/zerotier-central-api/.openapi-generator/FILES @@ -0,0 +1,56 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +Cargo.toml +README.md +docs/ApiToken.md +docs/AuthMethods.md +docs/InviteStatus.md +docs/IpRange.md +docs/Ipv4AssignMode.md +docs/Ipv6AssignMode.md +docs/Member.md +docs/MemberConfig.md +docs/Network.md +docs/NetworkApi.md +docs/NetworkConfig.md +docs/NetworkConfigDns.md +docs/NetworkMemberApi.md +docs/Organization.md +docs/OrganizationInvitation.md +docs/OrganizationMember.md +docs/OrganizationsApi.md +docs/Permissions.md +docs/RandomToken.md +docs/Route.md +docs/User.md +docs/UserApi.md +docs/UtilApi.md +git_push.sh +src/apis/configuration.rs +src/apis/mod.rs +src/apis/network_api.rs +src/apis/network_member_api.rs +src/apis/organizations_api.rs +src/apis/user_api.rs +src/apis/util_api.rs +src/lib.rs +src/models/api_token.rs +src/models/auth_methods.rs +src/models/invite_status.rs +src/models/ip_range.rs +src/models/ipv4_assign_mode.rs +src/models/ipv6_assign_mode.rs +src/models/member.rs +src/models/member_config.rs +src/models/mod.rs +src/models/network.rs +src/models/network_config.rs +src/models/network_config_dns.rs +src/models/organization.rs +src/models/organization_invitation.rs +src/models/organization_member.rs +src/models/permissions.rs +src/models/random_token.rs +src/models/route.rs +src/models/user.rs diff --git a/zerotier-central-api/.openapi-generator/VERSION b/zerotier-central-api/.openapi-generator/VERSION new file mode 100644 index 0000000..6555596 --- /dev/null +++ b/zerotier-central-api/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.2.0-SNAPSHOT \ No newline at end of file diff --git a/zerotier-central-api/.travis.yml b/zerotier-central-api/.travis.yml new file mode 100644 index 0000000..22761ba --- /dev/null +++ b/zerotier-central-api/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/zerotier-central-api/Cargo.toml b/zerotier-central-api/Cargo.toml new file mode 100644 index 0000000..73d80cc --- /dev/null +++ b/zerotier-central-api/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "zerotier-central-api" +version = "1.0.0" +edition = "2018" +description = "OpenAPI bindings to zerotier-one service" +authors = ["Erik Hollensbe ", "Adam Ierymenko "] +license = "BSD-3-Clause" + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "^2.2" +[dependencies.reqwest] +version = "^0.11" +features = ["json", "multipart"] + +[dev-dependencies] diff --git a/zerotier-central-api/README.md b/zerotier-central-api/README.md new file mode 100644 index 0000000..4e806e3 --- /dev/null +++ b/zerotier-central-api/README.md @@ -0,0 +1,84 @@ +# Rust API client for zerotier-central-api + +ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: v1 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.RustClientCodegen +For more information, please visit [https://discuss.zerotier.com](https://discuss.zerotier.com) + +## Installation + +Put the package under your project folder and add the following to `Cargo.toml` under `[dependencies]`: + +``` + openapi = { path = "./generated" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://my.zerotier.com/api* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*NetworkApi* | [**delete_network**](docs/NetworkApi.md#delete_network) | **delete** /network/{networkID} | delete network +*NetworkApi* | [**get_network_by_id**](docs/NetworkApi.md#get_network_by_id) | **get** /network/{networkID} | Get network by ID +*NetworkApi* | [**get_network_list**](docs/NetworkApi.md#get_network_list) | **get** /network | Returns a list of Networks you have access to. +*NetworkApi* | [**new_network**](docs/NetworkApi.md#new_network) | **post** /network | Create a new network. +*NetworkApi* | [**update_network**](docs/NetworkApi.md#update_network) | **post** /network/{networkID} | update network configuration +*NetworkMemberApi* | [**delete_network_member**](docs/NetworkMemberApi.md#delete_network_member) | **delete** /network/{networkID}/member/{memberID} | Delete a network member +*NetworkMemberApi* | [**get_network_member**](docs/NetworkMemberApi.md#get_network_member) | **get** /network/{networkID}/member/{memberID} | Return an individual member on a network +*NetworkMemberApi* | [**get_network_member_list**](docs/NetworkMemberApi.md#get_network_member_list) | **get** /network/{networkID}/member | Returns a list of Members on the network. +*NetworkMemberApi* | [**update_network_member**](docs/NetworkMemberApi.md#update_network_member) | **post** /network/{networkID}/member/{memberID} | Modify a network member +*OrganizationsApi* | [**accept_invitation**](docs/OrganizationsApi.md#accept_invitation) | **post** /org-invitation/{inviteID} | Accept organization invitation +*OrganizationsApi* | [**decline_invitation**](docs/OrganizationsApi.md#decline_invitation) | **delete** /org-invitation/{inviteID} | Decline organization invitation +*OrganizationsApi* | [**get_invitation_by_id**](docs/OrganizationsApi.md#get_invitation_by_id) | **get** /org-invitation/{inviteID} | Get organization invitation +*OrganizationsApi* | [**get_organization**](docs/OrganizationsApi.md#get_organization) | **get** /org | Get the current user's organization +*OrganizationsApi* | [**get_organization_by_id**](docs/OrganizationsApi.md#get_organization_by_id) | **get** /org/{orgID} | Get organization by ID +*OrganizationsApi* | [**get_organization_invitation_list**](docs/OrganizationsApi.md#get_organization_invitation_list) | **get** /org-invitation | Get list of organization invitations +*OrganizationsApi* | [**get_organization_members**](docs/OrganizationsApi.md#get_organization_members) | **get** /org/{orgID}/user | Get list of organization members +*OrganizationsApi* | [**invite_user_by_email**](docs/OrganizationsApi.md#invite_user_by_email) | **post** /org-invitation | Invite a user to your organization by email +*UserApi* | [**add_api_token**](docs/UserApi.md#add_api_token) | **post** /user/{userID}/token | Add an API token +*UserApi* | [**delete_api_token**](docs/UserApi.md#delete_api_token) | **delete** /user/{userID}/token/{tokenName} | Delete API Token +*UserApi* | [**delete_user_by_id**](docs/UserApi.md#delete_user_by_id) | **delete** /user/{userID} | Delete user +*UserApi* | [**get_user_by_id**](docs/UserApi.md#get_user_by_id) | **get** /user/{userID} | Get user record +*UserApi* | [**update_user_by_id**](docs/UserApi.md#update_user_by_id) | **post** /user/{userID} | Update user record (SMS number or Display Name only) +*UtilApi* | [**get_random_token**](docs/UtilApi.md#get_random_token) | **get** /randomToken | Get a random 32 character token + + +## Documentation For Models + + - [ApiToken](docs/ApiToken.md) + - [AuthMethods](docs/AuthMethods.md) + - [InviteStatus](docs/InviteStatus.md) + - [IpRange](docs/IpRange.md) + - [Ipv4AssignMode](docs/Ipv4AssignMode.md) + - [Ipv6AssignMode](docs/Ipv6AssignMode.md) + - [Member](docs/Member.md) + - [MemberConfig](docs/MemberConfig.md) + - [Network](docs/Network.md) + - [NetworkConfig](docs/NetworkConfig.md) + - [NetworkConfigDns](docs/NetworkConfigDns.md) + - [Organization](docs/Organization.md) + - [OrganizationInvitation](docs/OrganizationInvitation.md) + - [OrganizationMember](docs/OrganizationMember.md) + - [Permissions](docs/Permissions.md) + - [RandomToken](docs/RandomToken.md) + - [Route](docs/Route.md) + - [User](docs/User.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + + + diff --git a/zerotier-central-api/docs/ApiToken.md b/zerotier-central-api/docs/ApiToken.md new file mode 100644 index 0000000..2f33e43 --- /dev/null +++ b/zerotier-central-api/docs/ApiToken.md @@ -0,0 +1,12 @@ +# ApiToken + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**token_name** | Option<**String**> | user specified token name | [optional] +**token** | Option<**String**> | API Token. Minimum 32 characters. This token is encrypted in the database and can not be retrieved once set | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/AuthMethods.md b/zerotier-central-api/docs/AuthMethods.md new file mode 100644 index 0000000..c7c2c07 --- /dev/null +++ b/zerotier-central-api/docs/AuthMethods.md @@ -0,0 +1,13 @@ +# AuthMethods + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**local** | Option<**String**> | email address for built-in authentication | [optional][readonly] +**google** | Option<**String**> | Google OIDC ID | [optional][readonly] +**oidc** | Option<**String**> | Generic OIDC ID | [optional][readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/InviteStatus.md b/zerotier-central-api/docs/InviteStatus.md new file mode 100644 index 0000000..74709eb --- /dev/null +++ b/zerotier-central-api/docs/InviteStatus.md @@ -0,0 +1,10 @@ +# InviteStatus + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/IpRange.md b/zerotier-central-api/docs/IpRange.md new file mode 100644 index 0000000..ddcb0a3 --- /dev/null +++ b/zerotier-central-api/docs/IpRange.md @@ -0,0 +1,12 @@ +# IpRange + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ip_range_start** | Option<**String**> | | [optional] +**ip_range_end** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/Ipv4AssignMode.md b/zerotier-central-api/docs/Ipv4AssignMode.md new file mode 100644 index 0000000..39a1fe8 --- /dev/null +++ b/zerotier-central-api/docs/Ipv4AssignMode.md @@ -0,0 +1,11 @@ +# Ipv4AssignMode + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**zt** | Option<**bool**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/Ipv6AssignMode.md b/zerotier-central-api/docs/Ipv6AssignMode.md new file mode 100644 index 0000000..74813e9 --- /dev/null +++ b/zerotier-central-api/docs/Ipv6AssignMode.md @@ -0,0 +1,13 @@ +# Ipv6AssignMode + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**var_6plane** | Option<**bool**> | | [optional] +**rfc4193** | Option<**bool**> | | [optional] +**zt** | Option<**bool**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/Member.md b/zerotier-central-api/docs/Member.md new file mode 100644 index 0000000..eecb46c --- /dev/null +++ b/zerotier-central-api/docs/Member.md @@ -0,0 +1,24 @@ +# Member + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**String**> | concatenation of network ID and member ID | [optional][readonly] +**clock** | Option<**i64**> | | [optional][readonly] +**network_id** | Option<**String**> | | [optional][readonly] +**node_id** | Option<**String**> | ZeroTier ID of the member | [optional][readonly] +**controller_id** | Option<**String**> | | [optional][readonly] +**hidden** | Option<**bool**> | Whether or not the member is hidden in the UI | [optional] +**name** | Option<**String**> | User defined name of the member | [optional] +**description** | Option<**String**> | User defined description of the member | [optional] +**config** | Option<[**crate::models::MemberConfig**](MemberConfig.md)> | | [optional] +**last_online** | Option<**i64**> | Last seen time of the member | [optional][readonly] +**physical_address** | Option<**String**> | IP address the member last spoke to the controller via | [optional][readonly] +**client_version** | Option<**String**> | ZeroTier version the member is running | [optional][readonly] +**protocol_version** | Option<**i32**> | ZeroTier protocol version | [optional][readonly] +**supports_rules_engine** | Option<**bool**> | Whether or not the client version is new enough to support the rules engine (1.4.0+) | [optional][readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/MemberConfig.md b/zerotier-central-api/docs/MemberConfig.md new file mode 100644 index 0000000..ae34de8 --- /dev/null +++ b/zerotier-central-api/docs/MemberConfig.md @@ -0,0 +1,26 @@ +# MemberConfig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**active_bridge** | Option<**bool**> | Allow the member to be a bridge on the network | [optional] +**authorized** | Option<**bool**> | Is the member authorized on the network | [optional] +**capabilities** | Option<**Vec**> | | [optional] +**creation_time** | Option<**i64**> | Time the member was created or first tried to join the network | [optional][readonly] +**id** | Option<**String**> | ID of the member node. This is the 10 digit identifier that identifies a ZeroTier node. | [optional][readonly] +**identity** | Option<**String**> | Public Key of the member's Identity | [optional][readonly] +**ip_assignments** | Option<**Vec**> | List of assigned IP addresses | [optional] +**last_authorized_time** | Option<**i64**> | Time the member was authorized on the network | [optional][readonly] +**last_deauthorized_time** | Option<**i64**> | Time the member was deauthorized on the network | [optional][readonly] +**no_auto_assign_ips** | Option<**bool**> | Exempt this member from the IP auto assignment pool on a Network | [optional] +**revision** | Option<**i32**> | Member record revision count | [optional][readonly] +**tags** | Option<[**Vec>**](array.md)> | Array of 2 member tuples of tag [ID, tag value] | [optional] +**v_major** | Option<**i32**> | Major version of the client | [optional][readonly] +**v_minor** | Option<**i32**> | Minor version of the client | [optional][readonly] +**v_rev** | Option<**i32**> | Revision number of the client | [optional][readonly] +**v_proto** | Option<**i32**> | Protocol version of the client | [optional][readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/Network.md b/zerotier-central-api/docs/Network.md new file mode 100644 index 0000000..afedcd5 --- /dev/null +++ b/zerotier-central-api/docs/Network.md @@ -0,0 +1,22 @@ +# Network + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**String**> | | [optional][readonly] +**clock** | Option<**i64**> | | [optional][readonly] +**config** | Option<[**crate::models::NetworkConfig**](NetworkConfig.md)> | | [optional] +**description** | Option<**String**> | | [optional] +**rules_source** | Option<**String**> | | [optional] +**permissions** | Option<[**::std::collections::HashMap**](Permissions.md)> | | [optional] +**owner_id** | Option<**String**> | | [optional] +**online_member_count** | Option<**i32**> | | [optional][readonly] +**authorized_member_count** | Option<**i32**> | | [optional][readonly] +**total_member_count** | Option<**i32**> | | [optional][readonly] +**capabilities_by_name** | Option<[**serde_json::Value**](.md)> | | [optional] +**tags_by_name** | Option<[**serde_json::Value**](.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/NetworkApi.md b/zerotier-central-api/docs/NetworkApi.md new file mode 100644 index 0000000..9e17ed5 --- /dev/null +++ b/zerotier-central-api/docs/NetworkApi.md @@ -0,0 +1,153 @@ +# \NetworkApi + +All URIs are relative to *https://my.zerotier.com/api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_network**](NetworkApi.md#delete_network) | **delete** /network/{networkID} | delete network +[**get_network_by_id**](NetworkApi.md#get_network_by_id) | **get** /network/{networkID} | Get network by ID +[**get_network_list**](NetworkApi.md#get_network_list) | **get** /network | Returns a list of Networks you have access to. +[**new_network**](NetworkApi.md#new_network) | **post** /network | Create a new network. +[**update_network**](NetworkApi.md#update_network) | **post** /network/{networkID} | update network configuration + + + +## delete_network + +> delete_network(network_id) +delete network + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network | [required] | + +### Return type + + (empty response body) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_network_by_id + +> crate::models::Network get_network_by_id(network_id) +Get network by ID + +Returns a single network + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network to return | [required] | + +### Return type + +[**crate::models::Network**](Network.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_network_list + +> Vec get_network_list() +Returns a list of Networks you have access to. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](Network.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## new_network + +> crate::models::Network new_network(body) +Create a new network. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | **serde_json::Value** | empty JSON object | [required] | + +### Return type + +[**crate::models::Network**](Network.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_network + +> crate::models::Network update_network(network_id, network) +update network configuration + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network to change | [required] | +**network** | [**Network**](Network.md) | Network object JSON | [required] | + +### Return type + +[**crate::models::Network**](Network.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/zerotier-central-api/docs/NetworkConfig.md b/zerotier-central-api/docs/NetworkConfig.md new file mode 100644 index 0000000..bea88ae --- /dev/null +++ b/zerotier-central-api/docs/NetworkConfig.md @@ -0,0 +1,26 @@ +# NetworkConfig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**String**> | Network ID | [optional][readonly] +**creation_time** | Option<**i64**> | Time the network was created | [optional][readonly] +**capabilities** | Option<[**Vec**](serde_json::Value.md)> | Array of network capabilities | [optional] +**dns** | Option<[**crate::models::NetworkConfigDns**](NetworkConfig_dns.md)> | | [optional] +**enable_broadcast** | Option<**bool**> | Enable broadcast packets on the network | [optional] +**ip_assignment_pools** | Option<[**Vec**](IPRange.md)> | Range of IP addresses for the auto assign pool | [optional] +**last_modified** | Option<**i64**> | Time the network was last modified | [optional][readonly] +**mtu** | Option<**i32**> | MTU to set on the client virtual network adapter | [optional] +**multicast_limit** | Option<**i32**> | Maximum number of recipients per multicast or broadcast. Warning - Setting this to 0 will disable IPv4 communication on your network! | [optional] +**name** | Option<**String**> | | [optional] +**private** | Option<**bool**> | Whether or not the network is private. If false, members will *NOT* need to be authorized to join. | [optional] +**routes** | Option<[**Vec**](Route.md)> | | [optional] +**rules** | Option<[**Vec**](serde_json::Value.md)> | | [optional] +**tags** | Option<[**Vec**](serde_json::Value.md)> | | [optional] +**v4_assign_mode** | Option<[**crate::models::Ipv4AssignMode**](IPV4AssignMode.md)> | | [optional] +**v6_assign_mode** | Option<[**crate::models::Ipv6AssignMode**](IPV6AssignMode.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/NetworkConfigDns.md b/zerotier-central-api/docs/NetworkConfigDns.md new file mode 100644 index 0000000..db00548 --- /dev/null +++ b/zerotier-central-api/docs/NetworkConfigDns.md @@ -0,0 +1,12 @@ +# NetworkConfigDns + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**domain** | Option<**String**> | Search domain to use for DNS records | [optional] +**servers** | Option<**Vec**> | IP address of unicast DNS service | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/NetworkMemberApi.md b/zerotier-central-api/docs/NetworkMemberApi.md new file mode 100644 index 0000000..64b5f2d --- /dev/null +++ b/zerotier-central-api/docs/NetworkMemberApi.md @@ -0,0 +1,128 @@ +# \NetworkMemberApi + +All URIs are relative to *https://my.zerotier.com/api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_network_member**](NetworkMemberApi.md#delete_network_member) | **delete** /network/{networkID}/member/{memberID} | Delete a network member +[**get_network_member**](NetworkMemberApi.md#get_network_member) | **get** /network/{networkID}/member/{memberID} | Return an individual member on a network +[**get_network_member_list**](NetworkMemberApi.md#get_network_member_list) | **get** /network/{networkID}/member | Returns a list of Members on the network. +[**update_network_member**](NetworkMemberApi.md#update_network_member) | **post** /network/{networkID}/member/{memberID} | Modify a network member + + + +## delete_network_member + +> delete_network_member(network_id, member_id) +Delete a network member + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network | [required] | +**member_id** | **String** | ID of the member | [required] | + +### Return type + + (empty response body) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_network_member + +> crate::models::Member get_network_member(network_id, member_id) +Return an individual member on a network + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network | [required] | +**member_id** | **String** | ID of the member | [required] | + +### Return type + +[**crate::models::Member**](Member.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_network_member_list + +> Vec get_network_member_list(network_id) +Returns a list of Members on the network. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network to return | [required] | + +### Return type + +[**Vec**](Member.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_network_member + +> crate::models::Member update_network_member(network_id, member_id, member) +Modify a network member + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network | [required] | +**member_id** | **String** | ID of the member | [required] | +**member** | [**Member**](Member.md) | Member object JSON | [required] | + +### Return type + +[**crate::models::Member**](Member.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/zerotier-central-api/docs/Organization.md b/zerotier-central-api/docs/Organization.md new file mode 100644 index 0000000..dd75811 --- /dev/null +++ b/zerotier-central-api/docs/Organization.md @@ -0,0 +1,14 @@ +# Organization + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**String**> | Organization ID | [optional] +**owner_id** | Option<**String**> | User ID of the organization owner | [optional][readonly] +**owner_email** | Option<**String**> | Organization owner's email address | [optional][readonly] +**members** | Option<[**Vec**](OrganizationMember.md)> | List of organization members | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/OrganizationInvitation.md b/zerotier-central-api/docs/OrganizationInvitation.md new file mode 100644 index 0000000..9c212d1 --- /dev/null +++ b/zerotier-central-api/docs/OrganizationInvitation.md @@ -0,0 +1,17 @@ +# OrganizationInvitation + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**org_id** | Option<**String**> | Organization ID | [optional][readonly] +**email** | Option<**String**> | Email address of invitee | [optional] +**id** | Option<**String**> | Invitation ID | [optional][readonly] +**creation_time** | Option<**i32**> | Creation time of the invite | [optional][readonly] +**status** | Option<[**crate::models::InviteStatus**](InviteStatus.md)> | Invitation status | [optional][readonly] +**update_time** | Option<**i64**> | Last updated time of the invitation | [optional][readonly] +**owner_email** | Option<**String**> | Organization owner email address | [optional][readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/OrganizationMember.md b/zerotier-central-api/docs/OrganizationMember.md new file mode 100644 index 0000000..ad93188 --- /dev/null +++ b/zerotier-central-api/docs/OrganizationMember.md @@ -0,0 +1,14 @@ +# OrganizationMember + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**org_id** | Option<**String**> | Organization ID | [optional][readonly] +**user_id** | Option<**String**> | User ID | [optional] +**name** | Option<**String**> | Organization member display name | [optional][readonly] +**email** | Option<**String**> | Organization member email address | [optional][readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/OrganizationsApi.md b/zerotier-central-api/docs/OrganizationsApi.md new file mode 100644 index 0000000..e3cc2ae --- /dev/null +++ b/zerotier-central-api/docs/OrganizationsApi.md @@ -0,0 +1,234 @@ +# \OrganizationsApi + +All URIs are relative to *https://my.zerotier.com/api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**accept_invitation**](OrganizationsApi.md#accept_invitation) | **post** /org-invitation/{inviteID} | Accept organization invitation +[**decline_invitation**](OrganizationsApi.md#decline_invitation) | **delete** /org-invitation/{inviteID} | Decline organization invitation +[**get_invitation_by_id**](OrganizationsApi.md#get_invitation_by_id) | **get** /org-invitation/{inviteID} | Get organization invitation +[**get_organization**](OrganizationsApi.md#get_organization) | **get** /org | Get the current user's organization +[**get_organization_by_id**](OrganizationsApi.md#get_organization_by_id) | **get** /org/{orgID} | Get organization by ID +[**get_organization_invitation_list**](OrganizationsApi.md#get_organization_invitation_list) | **get** /org-invitation | Get list of organization invitations +[**get_organization_members**](OrganizationsApi.md#get_organization_members) | **get** /org/{orgID}/user | Get list of organization members +[**invite_user_by_email**](OrganizationsApi.md#invite_user_by_email) | **post** /org-invitation | Invite a user to your organization by email + + + +## accept_invitation + +> crate::models::OrganizationInvitation accept_invitation(invite_id) +Accept organization invitation + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**invite_id** | **String** | Invitation ID | [required] | + +### Return type + +[**crate::models::OrganizationInvitation**](OrganizationInvitation.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## decline_invitation + +> decline_invitation(invite_id) +Decline organization invitation + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**invite_id** | **String** | Invitation ID | [required] | + +### Return type + + (empty response body) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_invitation_by_id + +> crate::models::OrganizationInvitation get_invitation_by_id(invite_id) +Get organization invitation + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**invite_id** | **String** | Invitation ID | [required] | + +### Return type + +[**crate::models::OrganizationInvitation**](OrganizationInvitation.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_organization + +> crate::models::Organization get_organization() +Get the current user's organization + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::Organization**](Organization.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_organization_by_id + +> crate::models::Organization get_organization_by_id(org_id) +Get organization by ID + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**org_id** | **String** | Organization ID | [required] | + +### Return type + +[**crate::models::Organization**](Organization.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_organization_invitation_list + +> Vec get_organization_invitation_list() +Get list of organization invitations + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](OrganizationInvitation.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_organization_members + +> crate::models::OrganizationMember get_organization_members(org_id) +Get list of organization members + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**org_id** | **String** | Organization ID | [required] | + +### Return type + +[**crate::models::OrganizationMember**](OrganizationMember.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## invite_user_by_email + +> crate::models::OrganizationInvitation invite_user_by_email(organization_invitation) +Invite a user to your organization by email + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**organization_invitation** | [**OrganizationInvitation**](OrganizationInvitation.md) | Organization Invitation JSON object | [required] | + +### Return type + +[**crate::models::OrganizationInvitation**](OrganizationInvitation.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/zerotier-central-api/docs/Permissions.md b/zerotier-central-api/docs/Permissions.md new file mode 100644 index 0000000..80cf624 --- /dev/null +++ b/zerotier-central-api/docs/Permissions.md @@ -0,0 +1,14 @@ +# Permissions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**a** | Option<**bool**> | Authorize permission | [optional] +**d** | Option<**bool**> | Delete permission | [optional] +**m** | Option<**bool**> | Modify network settings permission | [optional] +**r** | Option<**bool**> | Read network settings permission | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/RandomToken.md b/zerotier-central-api/docs/RandomToken.md new file mode 100644 index 0000000..9e6bb53 --- /dev/null +++ b/zerotier-central-api/docs/RandomToken.md @@ -0,0 +1,13 @@ +# RandomToken + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**clock** | Option<**i64**> | Current time on server | [optional][readonly] +**hex** | Option<**String**> | hex encoded random bytes of the token | [optional][readonly] +**token** | Option<**String**> | Random 32 character token | [optional][readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/Route.md b/zerotier-central-api/docs/Route.md new file mode 100644 index 0000000..d1748c2 --- /dev/null +++ b/zerotier-central-api/docs/Route.md @@ -0,0 +1,12 @@ +# Route + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**target** | Option<**String**> | | [optional] +**via** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/User.md b/zerotier-central-api/docs/User.md new file mode 100644 index 0000000..083af1e --- /dev/null +++ b/zerotier-central-api/docs/User.md @@ -0,0 +1,18 @@ +# User + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**String**> | User ID | [optional][readonly] +**org_id** | Option<**String**> | Organization ID | [optional][readonly] +**global_permissions** | Option<[**crate::models::Permissions**](Permissions.md)> | | [optional][readonly] +**display_name** | Option<**String**> | Display Name | [optional] +**email** | Option<**String**> | User email address | [optional][readonly] +**auth** | Option<[**crate::models::AuthMethods**](AuthMethods.md)> | | [optional][readonly] +**sms_number** | Option<**String**> | SMS number | [optional] +**tokens** | Option<**Vec**> | List of API token names. | [optional][readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-central-api/docs/UserApi.md b/zerotier-central-api/docs/UserApi.md new file mode 100644 index 0000000..8016ba7 --- /dev/null +++ b/zerotier-central-api/docs/UserApi.md @@ -0,0 +1,158 @@ +# \UserApi + +All URIs are relative to *https://my.zerotier.com/api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_api_token**](UserApi.md#add_api_token) | **post** /user/{userID}/token | Add an API token +[**delete_api_token**](UserApi.md#delete_api_token) | **delete** /user/{userID}/token/{tokenName} | Delete API Token +[**delete_user_by_id**](UserApi.md#delete_user_by_id) | **delete** /user/{userID} | Delete user +[**get_user_by_id**](UserApi.md#get_user_by_id) | **get** /user/{userID} | Get user record +[**update_user_by_id**](UserApi.md#update_user_by_id) | **post** /user/{userID} | Update user record (SMS number or Display Name only) + + + +## add_api_token + +> crate::models::ApiToken add_api_token(user_id, api_token) +Add an API token + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user_id** | **String** | User ID | [required] | +**api_token** | [**ApiToken**](ApiToken.md) | APIToken JSON object | [required] | + +### Return type + +[**crate::models::ApiToken**](APIToken.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_api_token + +> delete_api_token(user_id, token_name) +Delete API Token + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user_id** | **String** | User ID | [required] | +**token_name** | **String** | Token Name | [required] | + +### Return type + + (empty response body) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_user_by_id + +> delete_user_by_id(user_id) +Delete user + +Deletes the user and all associated networks. This is not reversible. Delete at your own risk. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user_id** | **String** | User ID | [required] | + +### Return type + + (empty response body) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_user_by_id + +> crate::models::User get_user_by_id(user_id) +Get user record + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user_id** | **String** | User ID | [required] | + +### Return type + +[**crate::models::User**](User.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_user_by_id + +> crate::models::User update_user_by_id(user_id, user) +Update user record (SMS number or Display Name only) + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user_id** | **String** | User ID | [required] | +**user** | [**User**](User.md) | User object JSON | [required] | + +### Return type + +[**crate::models::User**](User.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/zerotier-central-api/docs/UtilApi.md b/zerotier-central-api/docs/UtilApi.md new file mode 100644 index 0000000..ae2b3f6 --- /dev/null +++ b/zerotier-central-api/docs/UtilApi.md @@ -0,0 +1,36 @@ +# \UtilApi + +All URIs are relative to *https://my.zerotier.com/api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_random_token**](UtilApi.md#get_random_token) | **get** /randomToken | Get a random 32 character token + + + +## get_random_token + +> crate::models::RandomToken get_random_token() +Get a random 32 character token + +Get a random 32 character. Used by the web UI to generate API keys + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::RandomToken**](RandomToken.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/zerotier-central-api/git_push.sh b/zerotier-central-api/git_push.sh new file mode 100644 index 0000000..ced3be2 --- /dev/null +++ b/zerotier-central-api/git_push.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/zerotier-central-api/src/apis/configuration.rs b/zerotier-central-api/src/apis/configuration.rs new file mode 100644 index 0000000..5965c63 --- /dev/null +++ b/zerotier-central-api/src/apis/configuration.rs @@ -0,0 +1,52 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "https://my.zerotier.com/api".to_owned(), + user_agent: Some("OpenAPI-Generator/v1/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/zerotier-central-api/src/apis/mod.rs b/zerotier-central-api/src/apis/mod.rs new file mode 100644 index 0000000..51f89ed --- /dev/null +++ b/zerotier-central-api/src/apis/mod.rs @@ -0,0 +1,70 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub mod network_api; +pub mod network_member_api; +pub mod organizations_api; +pub mod user_api; +pub mod util_api; + +pub mod configuration; diff --git a/zerotier-central-api/src/apis/network_api.rs b/zerotier-central-api/src/apis/network_api.rs new file mode 100644 index 0000000..9b7ee68 --- /dev/null +++ b/zerotier-central-api/src/apis/network_api.rs @@ -0,0 +1,212 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method `delete_network` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteNetworkError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_network_by_id` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNetworkByIdError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_network_list` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNetworkListError { + Status403(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `new_network` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum NewNetworkError { + Status403(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `update_network` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateNetworkError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + + +pub async fn delete_network(configuration: &configuration::Configuration, network_id: &str) -> Result<(), Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}", configuration.base_path, networkID=crate::apis::urlencode(network_id)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns a single network +pub async fn get_network_by_id(configuration: &configuration::Configuration, network_id: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}", configuration.base_path, networkID=crate::apis::urlencode(network_id)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_network_list(configuration: &configuration::Configuration, ) -> Result, Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn new_network(configuration: &configuration::Configuration, body: serde_json::Value) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn update_network(configuration: &configuration::Configuration, network_id: &str, network: crate::models::Network) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}", configuration.base_path, networkID=crate::apis::urlencode(network_id)); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&network); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/zerotier-central-api/src/apis/network_member_api.rs b/zerotier-central-api/src/apis/network_member_api.rs new file mode 100644 index 0000000..bbc1c4c --- /dev/null +++ b/zerotier-central-api/src/apis/network_member_api.rs @@ -0,0 +1,175 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method `delete_network_member` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteNetworkMemberError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_network_member` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNetworkMemberError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_network_member_list` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNetworkMemberListError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `update_network_member` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateNetworkMemberError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + + +pub async fn delete_network_member(configuration: &configuration::Configuration, network_id: &str, member_id: &str) -> Result<(), Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}/member/{memberID}", configuration.base_path, networkID=crate::apis::urlencode(network_id), memberID=crate::apis::urlencode(member_id)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_network_member(configuration: &configuration::Configuration, network_id: &str, member_id: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}/member/{memberID}", configuration.base_path, networkID=crate::apis::urlencode(network_id), memberID=crate::apis::urlencode(member_id)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_network_member_list(configuration: &configuration::Configuration, network_id: &str) -> Result, Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}/member", configuration.base_path, networkID=crate::apis::urlencode(network_id)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn update_network_member(configuration: &configuration::Configuration, network_id: &str, member_id: &str, member: crate::models::Member) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}/member/{memberID}", configuration.base_path, networkID=crate::apis::urlencode(network_id), memberID=crate::apis::urlencode(member_id)); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&member); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/zerotier-central-api/src/apis/organizations_api.rs b/zerotier-central-api/src/apis/organizations_api.rs new file mode 100644 index 0000000..949d7a9 --- /dev/null +++ b/zerotier-central-api/src/apis/organizations_api.rs @@ -0,0 +1,331 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method `accept_invitation` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AcceptInvitationError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `decline_invitation` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeclineInvitationError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_invitation_by_id` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetInvitationByIdError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_organization` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrganizationError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_organization_by_id` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrganizationByIdError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_organization_invitation_list` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrganizationInvitationListError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_organization_members` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrganizationMembersError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `invite_user_by_email` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum InviteUserByEmailError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + + +pub async fn accept_invitation(configuration: &configuration::Configuration, invite_id: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/org-invitation/{inviteID}", configuration.base_path, inviteID=crate::apis::urlencode(invite_id)); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn decline_invitation(configuration: &configuration::Configuration, invite_id: &str) -> Result<(), Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/org-invitation/{inviteID}", configuration.base_path, inviteID=crate::apis::urlencode(invite_id)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_invitation_by_id(configuration: &configuration::Configuration, invite_id: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/org-invitation/{inviteID}", configuration.base_path, inviteID=crate::apis::urlencode(invite_id)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_organization(configuration: &configuration::Configuration, ) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/org", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_organization_by_id(configuration: &configuration::Configuration, org_id: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/org/{orgID}", configuration.base_path, orgID=crate::apis::urlencode(org_id)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_organization_invitation_list(configuration: &configuration::Configuration, ) -> Result, Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/org-invitation", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_organization_members(configuration: &configuration::Configuration, org_id: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/org/{orgID}/user", configuration.base_path, orgID=crate::apis::urlencode(org_id)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn invite_user_by_email(configuration: &configuration::Configuration, organization_invitation: crate::models::OrganizationInvitation) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/org-invitation", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_invitation); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/zerotier-central-api/src/apis/user_api.rs b/zerotier-central-api/src/apis/user_api.rs new file mode 100644 index 0000000..9b8f046 --- /dev/null +++ b/zerotier-central-api/src/apis/user_api.rs @@ -0,0 +1,217 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method `add_api_token` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddApiTokenError { + Status400(), + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `delete_api_token` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteApiTokenError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `delete_user_by_id` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteUserByIdError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_user_by_id` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetUserByIdError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `update_user_by_id` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateUserByIdError { + Status401(), + Status403(), + Status404(), + UnknownValue(serde_json::Value), +} + + +pub async fn add_api_token(configuration: &configuration::Configuration, user_id: &str, api_token: crate::models::ApiToken) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/user/{userID}/token", configuration.base_path, userID=crate::apis::urlencode(user_id)); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&api_token); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn delete_api_token(configuration: &configuration::Configuration, user_id: &str, token_name: &str) -> Result<(), Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/user/{userID}/token/{tokenName}", configuration.base_path, userID=crate::apis::urlencode(user_id), tokenName=crate::apis::urlencode(token_name)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Deletes the user and all associated networks. This is not reversible. Delete at your own risk. +pub async fn delete_user_by_id(configuration: &configuration::Configuration, user_id: &str) -> Result<(), Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/user/{userID}", configuration.base_path, userID=crate::apis::urlencode(user_id)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_user_by_id(configuration: &configuration::Configuration, user_id: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/user/{userID}", configuration.base_path, userID=crate::apis::urlencode(user_id)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn update_user_by_id(configuration: &configuration::Configuration, user_id: &str, user: crate::models::User) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/user/{userID}", configuration.base_path, userID=crate::apis::urlencode(user_id)); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&user); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/zerotier-central-api/src/apis/util_api.rs b/zerotier-central-api/src/apis/util_api.rs new file mode 100644 index 0000000..e7f7ae3 --- /dev/null +++ b/zerotier-central-api/src/apis/util_api.rs @@ -0,0 +1,55 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method `get_random_token` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRandomTokenError { + UnknownValue(serde_json::Value), +} + + +/// Get a random 32 character. Used by the web UI to generate API keys +pub async fn get_random_token(configuration: &configuration::Configuration, ) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/randomToken", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/zerotier-central-api/src/lib.rs b/zerotier-central-api/src/lib.rs new file mode 100644 index 0000000..c1dd666 --- /dev/null +++ b/zerotier-central-api/src/lib.rs @@ -0,0 +1,10 @@ +#[macro_use] +extern crate serde_derive; + +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/zerotier-central-api/src/models/api_token.rs b/zerotier-central-api/src/models/api_token.rs new file mode 100644 index 0000000..9df9962 --- /dev/null +++ b/zerotier-central-api/src/models/api_token.rs @@ -0,0 +1,33 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct ApiToken { + /// user specified token name + #[serde(rename = "tokenName", skip_serializing_if = "Option::is_none")] + pub token_name: Option, + /// API Token. Minimum 32 characters. This token is encrypted in the database and can not be retrieved once set + #[serde(rename = "token", skip_serializing_if = "Option::is_none")] + pub token: Option, +} + +impl ApiToken { + pub fn new() -> ApiToken { + ApiToken { + token_name: None, + token: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/auth_methods.rs b/zerotier-central-api/src/models/auth_methods.rs new file mode 100644 index 0000000..0642f10 --- /dev/null +++ b/zerotier-central-api/src/models/auth_methods.rs @@ -0,0 +1,37 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct AuthMethods { + /// email address for built-in authentication + #[serde(rename = "local", skip_serializing_if = "Option::is_none")] + pub local: Option, + /// Google OIDC ID + #[serde(rename = "google", skip_serializing_if = "Option::is_none")] + pub google: Option, + /// Generic OIDC ID + #[serde(rename = "oidc", skip_serializing_if = "Option::is_none")] + pub oidc: Option, +} + +impl AuthMethods { + pub fn new() -> AuthMethods { + AuthMethods { + local: None, + google: None, + oidc: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/invite_status.rs b/zerotier-central-api/src/models/invite_status.rs new file mode 100644 index 0000000..3e2fd55 --- /dev/null +++ b/zerotier-central-api/src/models/invite_status.rs @@ -0,0 +1,36 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum InviteStatus { + #[serde(rename = "pending")] + Pending, + #[serde(rename = "accepted")] + Accepted, + #[serde(rename = "canceled")] + Canceled, + +} + +impl ToString for InviteStatus { + fn to_string(&self) -> String { + match self { + Self::Pending => String::from("pending"), + Self::Accepted => String::from("accepted"), + Self::Canceled => String::from("canceled"), + } + } +} + + + + diff --git a/zerotier-central-api/src/models/ip_range.rs b/zerotier-central-api/src/models/ip_range.rs new file mode 100644 index 0000000..d32ee0e --- /dev/null +++ b/zerotier-central-api/src/models/ip_range.rs @@ -0,0 +1,31 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct IpRange { + #[serde(rename = "ipRangeStart", skip_serializing_if = "Option::is_none")] + pub ip_range_start: Option, + #[serde(rename = "ipRangeEnd", skip_serializing_if = "Option::is_none")] + pub ip_range_end: Option, +} + +impl IpRange { + pub fn new() -> IpRange { + IpRange { + ip_range_start: None, + ip_range_end: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/ipv4_assign_mode.rs b/zerotier-central-api/src/models/ipv4_assign_mode.rs new file mode 100644 index 0000000..107f023 --- /dev/null +++ b/zerotier-central-api/src/models/ipv4_assign_mode.rs @@ -0,0 +1,28 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Ipv4AssignMode { + #[serde(rename = "zt", skip_serializing_if = "Option::is_none")] + pub zt: Option, +} + +impl Ipv4AssignMode { + pub fn new() -> Ipv4AssignMode { + Ipv4AssignMode { + zt: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/ipv6_assign_mode.rs b/zerotier-central-api/src/models/ipv6_assign_mode.rs new file mode 100644 index 0000000..d1085b1 --- /dev/null +++ b/zerotier-central-api/src/models/ipv6_assign_mode.rs @@ -0,0 +1,34 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Ipv6AssignMode { + #[serde(rename = "6plane", skip_serializing_if = "Option::is_none")] + pub var_6plane: Option, + #[serde(rename = "rfc4193", skip_serializing_if = "Option::is_none")] + pub rfc4193: Option, + #[serde(rename = "zt", skip_serializing_if = "Option::is_none")] + pub zt: Option, +} + +impl Ipv6AssignMode { + pub fn new() -> Ipv6AssignMode { + Ipv6AssignMode { + var_6plane: None, + rfc4193: None, + zt: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/member.rs b/zerotier-central-api/src/models/member.rs new file mode 100644 index 0000000..c79d468 --- /dev/null +++ b/zerotier-central-api/src/models/member.rs @@ -0,0 +1,77 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Member { + /// concatenation of network ID and member ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "clock", skip_serializing_if = "Option::is_none")] + pub clock: Option, + #[serde(rename = "networkId", skip_serializing_if = "Option::is_none")] + pub network_id: Option, + /// ZeroTier ID of the member + #[serde(rename = "nodeId", skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(rename = "controllerId", skip_serializing_if = "Option::is_none")] + pub controller_id: Option, + /// Whether or not the member is hidden in the UI + #[serde(rename = "hidden", skip_serializing_if = "Option::is_none")] + pub hidden: Option, + /// User defined name of the member + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + /// User defined description of the member + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(rename = "config", skip_serializing_if = "Option::is_none")] + pub config: Option>, + /// Last seen time of the member + #[serde(rename = "lastOnline", skip_serializing_if = "Option::is_none")] + pub last_online: Option, + /// IP address the member last spoke to the controller via + #[serde(rename = "physicalAddress", skip_serializing_if = "Option::is_none")] + pub physical_address: Option, + /// ZeroTier version the member is running + #[serde(rename = "clientVersion", skip_serializing_if = "Option::is_none")] + pub client_version: Option, + /// ZeroTier protocol version + #[serde(rename = "protocolVersion", skip_serializing_if = "Option::is_none")] + pub protocol_version: Option, + /// Whether or not the client version is new enough to support the rules engine (1.4.0+) + #[serde(rename = "supportsRulesEngine", skip_serializing_if = "Option::is_none")] + pub supports_rules_engine: Option, +} + +impl Member { + pub fn new() -> Member { + Member { + id: None, + clock: None, + network_id: None, + node_id: None, + controller_id: None, + hidden: None, + name: None, + description: None, + config: None, + last_online: None, + physical_address: None, + client_version: None, + protocol_version: None, + supports_rules_engine: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/member_config.rs b/zerotier-central-api/src/models/member_config.rs new file mode 100644 index 0000000..34b5656 --- /dev/null +++ b/zerotier-central-api/src/models/member_config.rs @@ -0,0 +1,88 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct MemberConfig { + /// Allow the member to be a bridge on the network + #[serde(rename = "activeBridge", skip_serializing_if = "Option::is_none")] + pub active_bridge: Option, + /// Is the member authorized on the network + #[serde(rename = "authorized", skip_serializing_if = "Option::is_none")] + pub authorized: Option, + #[serde(rename = "capabilities", skip_serializing_if = "Option::is_none")] + pub capabilities: Option>, + /// Time the member was created or first tried to join the network + #[serde(rename = "creationTime", skip_serializing_if = "Option::is_none")] + pub creation_time: Option, + /// ID of the member node. This is the 10 digit identifier that identifies a ZeroTier node. + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Public Key of the member's Identity + #[serde(rename = "identity", skip_serializing_if = "Option::is_none")] + pub identity: Option, + /// List of assigned IP addresses + #[serde(rename = "ipAssignments", skip_serializing_if = "Option::is_none")] + pub ip_assignments: Option>, + /// Time the member was authorized on the network + #[serde(rename = "lastAuthorizedTime", skip_serializing_if = "Option::is_none")] + pub last_authorized_time: Option, + /// Time the member was deauthorized on the network + #[serde(rename = "lastDeauthorizedTime", skip_serializing_if = "Option::is_none")] + pub last_deauthorized_time: Option, + /// Exempt this member from the IP auto assignment pool on a Network + #[serde(rename = "noAutoAssignIps", skip_serializing_if = "Option::is_none")] + pub no_auto_assign_ips: Option, + /// Member record revision count + #[serde(rename = "revision", skip_serializing_if = "Option::is_none")] + pub revision: Option, + /// Array of 2 member tuples of tag [ID, tag value] + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>>, + /// Major version of the client + #[serde(rename = "vMajor", skip_serializing_if = "Option::is_none")] + pub v_major: Option, + /// Minor version of the client + #[serde(rename = "vMinor", skip_serializing_if = "Option::is_none")] + pub v_minor: Option, + /// Revision number of the client + #[serde(rename = "vRev", skip_serializing_if = "Option::is_none")] + pub v_rev: Option, + /// Protocol version of the client + #[serde(rename = "vProto", skip_serializing_if = "Option::is_none")] + pub v_proto: Option, +} + +impl MemberConfig { + pub fn new() -> MemberConfig { + MemberConfig { + active_bridge: None, + authorized: None, + capabilities: None, + creation_time: None, + id: None, + identity: None, + ip_assignments: None, + last_authorized_time: None, + last_deauthorized_time: None, + no_auto_assign_ips: None, + revision: None, + tags: None, + v_major: None, + v_minor: None, + v_rev: None, + v_proto: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/mod.rs b/zerotier-central-api/src/models/mod.rs new file mode 100644 index 0000000..d147c4b --- /dev/null +++ b/zerotier-central-api/src/models/mod.rs @@ -0,0 +1,36 @@ +pub mod api_token; +pub use self::api_token::ApiToken; +pub mod auth_methods; +pub use self::auth_methods::AuthMethods; +pub mod invite_status; +pub use self::invite_status::InviteStatus; +pub mod ip_range; +pub use self::ip_range::IpRange; +pub mod ipv4_assign_mode; +pub use self::ipv4_assign_mode::Ipv4AssignMode; +pub mod ipv6_assign_mode; +pub use self::ipv6_assign_mode::Ipv6AssignMode; +pub mod member; +pub use self::member::Member; +pub mod member_config; +pub use self::member_config::MemberConfig; +pub mod network; +pub use self::network::Network; +pub mod network_config; +pub use self::network_config::NetworkConfig; +pub mod network_config_dns; +pub use self::network_config_dns::NetworkConfigDns; +pub mod organization; +pub use self::organization::Organization; +pub mod organization_invitation; +pub use self::organization_invitation::OrganizationInvitation; +pub mod organization_member; +pub use self::organization_member::OrganizationMember; +pub mod permissions; +pub use self::permissions::Permissions; +pub mod random_token; +pub use self::random_token::RandomToken; +pub mod route; +pub use self::route::Route; +pub mod user; +pub use self::user::User; diff --git a/zerotier-central-api/src/models/network.rs b/zerotier-central-api/src/models/network.rs new file mode 100644 index 0000000..ff7254f --- /dev/null +++ b/zerotier-central-api/src/models/network.rs @@ -0,0 +1,63 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + +/// Network : Network object + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Network { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "clock", skip_serializing_if = "Option::is_none")] + pub clock: Option, + #[serde(rename = "config", skip_serializing_if = "Option::is_none")] + pub config: Option>, + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(rename = "rulesSource", skip_serializing_if = "Option::is_none")] + pub rules_source: Option, + #[serde(rename = "permissions", skip_serializing_if = "Option::is_none")] + pub permissions: Option<::std::collections::HashMap>, + #[serde(rename = "ownerId", skip_serializing_if = "Option::is_none")] + pub owner_id: Option, + #[serde(rename = "onlineMemberCount", skip_serializing_if = "Option::is_none")] + pub online_member_count: Option, + #[serde(rename = "authorizedMemberCount", skip_serializing_if = "Option::is_none")] + pub authorized_member_count: Option, + #[serde(rename = "totalMemberCount", skip_serializing_if = "Option::is_none")] + pub total_member_count: Option, + #[serde(rename = "capabilitiesByName", skip_serializing_if = "Option::is_none")] + pub capabilities_by_name: Option, + #[serde(rename = "tagsByName", skip_serializing_if = "Option::is_none")] + pub tags_by_name: Option, +} + +impl Network { + /// Network object + pub fn new() -> Network { + Network { + id: None, + clock: None, + config: None, + description: None, + rules_source: None, + permissions: None, + owner_id: None, + online_member_count: None, + authorized_member_count: None, + total_member_count: None, + capabilities_by_name: None, + tags_by_name: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/network_config.rs b/zerotier-central-api/src/models/network_config.rs new file mode 100644 index 0000000..7689b8c --- /dev/null +++ b/zerotier-central-api/src/models/network_config.rs @@ -0,0 +1,82 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct NetworkConfig { + /// Network ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Time the network was created + #[serde(rename = "creationTime", skip_serializing_if = "Option::is_none")] + pub creation_time: Option, + /// Array of network capabilities + #[serde(rename = "capabilities", skip_serializing_if = "Option::is_none")] + pub capabilities: Option>, + #[serde(rename = "dns", skip_serializing_if = "Option::is_none")] + pub dns: Option>, + /// Enable broadcast packets on the network + #[serde(rename = "enableBroadcast", skip_serializing_if = "Option::is_none")] + pub enable_broadcast: Option, + /// Range of IP addresses for the auto assign pool + #[serde(rename = "ipAssignmentPools", skip_serializing_if = "Option::is_none")] + pub ip_assignment_pools: Option>, + /// Time the network was last modified + #[serde(rename = "lastModified", skip_serializing_if = "Option::is_none")] + pub last_modified: Option, + /// MTU to set on the client virtual network adapter + #[serde(rename = "mtu", skip_serializing_if = "Option::is_none")] + pub mtu: Option, + /// Maximum number of recipients per multicast or broadcast. Warning - Setting this to 0 will disable IPv4 communication on your network! + #[serde(rename = "multicastLimit", skip_serializing_if = "Option::is_none")] + pub multicast_limit: Option, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + /// Whether or not the network is private. If false, members will *NOT* need to be authorized to join. + #[serde(rename = "private", skip_serializing_if = "Option::is_none")] + pub private: Option, + #[serde(rename = "routes", skip_serializing_if = "Option::is_none")] + pub routes: Option>, + #[serde(rename = "rules", skip_serializing_if = "Option::is_none")] + pub rules: Option>, + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, + #[serde(rename = "v4AssignMode", skip_serializing_if = "Option::is_none")] + pub v4_assign_mode: Option>, + #[serde(rename = "v6AssignMode", skip_serializing_if = "Option::is_none")] + pub v6_assign_mode: Option>, +} + +impl NetworkConfig { + pub fn new() -> NetworkConfig { + NetworkConfig { + id: None, + creation_time: None, + capabilities: None, + dns: None, + enable_broadcast: None, + ip_assignment_pools: None, + last_modified: None, + mtu: None, + multicast_limit: None, + name: None, + private: None, + routes: None, + rules: None, + tags: None, + v4_assign_mode: None, + v6_assign_mode: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/network_config_dns.rs b/zerotier-central-api/src/models/network_config_dns.rs new file mode 100644 index 0000000..cf88391 --- /dev/null +++ b/zerotier-central-api/src/models/network_config_dns.rs @@ -0,0 +1,33 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct NetworkConfigDns { + /// Search domain to use for DNS records + #[serde(rename = "domain", skip_serializing_if = "Option::is_none")] + pub domain: Option, + /// IP address of unicast DNS service + #[serde(rename = "servers", skip_serializing_if = "Option::is_none")] + pub servers: Option>, +} + +impl NetworkConfigDns { + pub fn new() -> NetworkConfigDns { + NetworkConfigDns { + domain: None, + servers: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/organization.rs b/zerotier-central-api/src/models/organization.rs new file mode 100644 index 0000000..b4b5d7d --- /dev/null +++ b/zerotier-central-api/src/models/organization.rs @@ -0,0 +1,41 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Organization { + /// Organization ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// User ID of the organization owner + #[serde(rename = "ownerId", skip_serializing_if = "Option::is_none")] + pub owner_id: Option, + /// Organization owner's email address + #[serde(rename = "ownerEmail", skip_serializing_if = "Option::is_none")] + pub owner_email: Option, + /// List of organization members + #[serde(rename = "members", skip_serializing_if = "Option::is_none")] + pub members: Option>, +} + +impl Organization { + pub fn new() -> Organization { + Organization { + id: None, + owner_id: None, + owner_email: None, + members: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/organization_invitation.rs b/zerotier-central-api/src/models/organization_invitation.rs new file mode 100644 index 0000000..51b63c7 --- /dev/null +++ b/zerotier-central-api/src/models/organization_invitation.rs @@ -0,0 +1,53 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct OrganizationInvitation { + /// Organization ID + #[serde(rename = "orgId", skip_serializing_if = "Option::is_none")] + pub org_id: Option, + /// Email address of invitee + #[serde(rename = "email", skip_serializing_if = "Option::is_none")] + pub email: Option, + /// Invitation ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Creation time of the invite + #[serde(rename = "creation_time", skip_serializing_if = "Option::is_none")] + pub creation_time: Option, + /// Invitation status + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option>, + /// Last updated time of the invitation + #[serde(rename = "update_time", skip_serializing_if = "Option::is_none")] + pub update_time: Option, + /// Organization owner email address + #[serde(rename = "ownerEmail", skip_serializing_if = "Option::is_none")] + pub owner_email: Option, +} + +impl OrganizationInvitation { + pub fn new() -> OrganizationInvitation { + OrganizationInvitation { + org_id: None, + email: None, + id: None, + creation_time: None, + status: None, + update_time: None, + owner_email: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/organization_member.rs b/zerotier-central-api/src/models/organization_member.rs new file mode 100644 index 0000000..cde7596 --- /dev/null +++ b/zerotier-central-api/src/models/organization_member.rs @@ -0,0 +1,41 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct OrganizationMember { + /// Organization ID + #[serde(rename = "orgId", skip_serializing_if = "Option::is_none")] + pub org_id: Option, + /// User ID + #[serde(rename = "userId", skip_serializing_if = "Option::is_none")] + pub user_id: Option, + /// Organization member display name + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + /// Organization member email address + #[serde(rename = "email", skip_serializing_if = "Option::is_none")] + pub email: Option, +} + +impl OrganizationMember { + pub fn new() -> OrganizationMember { + OrganizationMember { + org_id: None, + user_id: None, + name: None, + email: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/permissions.rs b/zerotier-central-api/src/models/permissions.rs new file mode 100644 index 0000000..6f3f300 --- /dev/null +++ b/zerotier-central-api/src/models/permissions.rs @@ -0,0 +1,41 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Permissions { + /// Authorize permission + #[serde(rename = "a", skip_serializing_if = "Option::is_none")] + pub a: Option, + /// Delete permission + #[serde(rename = "d", skip_serializing_if = "Option::is_none")] + pub d: Option, + /// Modify network settings permission + #[serde(rename = "m", skip_serializing_if = "Option::is_none")] + pub m: Option, + /// Read network settings permission + #[serde(rename = "r", skip_serializing_if = "Option::is_none")] + pub r: Option, +} + +impl Permissions { + pub fn new() -> Permissions { + Permissions { + a: None, + d: None, + m: None, + r: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/random_token.rs b/zerotier-central-api/src/models/random_token.rs new file mode 100644 index 0000000..9bd98f7 --- /dev/null +++ b/zerotier-central-api/src/models/random_token.rs @@ -0,0 +1,37 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct RandomToken { + /// Current time on server + #[serde(rename = "clock", skip_serializing_if = "Option::is_none")] + pub clock: Option, + /// hex encoded random bytes of the token + #[serde(rename = "hex", skip_serializing_if = "Option::is_none")] + pub hex: Option, + /// Random 32 character token + #[serde(rename = "token", skip_serializing_if = "Option::is_none")] + pub token: Option, +} + +impl RandomToken { + pub fn new() -> RandomToken { + RandomToken { + clock: None, + hex: None, + token: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/route.rs b/zerotier-central-api/src/models/route.rs new file mode 100644 index 0000000..69f87c0 --- /dev/null +++ b/zerotier-central-api/src/models/route.rs @@ -0,0 +1,31 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Route { + #[serde(rename = "target", skip_serializing_if = "Option::is_none")] + pub target: Option, + #[serde(rename = "via", skip_serializing_if = "Option::is_none")] + pub via: Option, +} + +impl Route { + pub fn new() -> Route { + Route { + target: None, + via: None, + } + } +} + + diff --git a/zerotier-central-api/src/models/user.rs b/zerotier-central-api/src/models/user.rs new file mode 100644 index 0000000..c4715a7 --- /dev/null +++ b/zerotier-central-api/src/models/user.rs @@ -0,0 +1,55 @@ +/* + * ZeroTier Central API + * + * ZeroTier Central Network Management Portal API.

All API requests must have an API token header specified in the Authorization: Bearer xxxxx format. You can generate your API key by logging into ZeroTier Central and creating a token on the Account page.

eg. curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network

+ * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct User { + /// User ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Organization ID + #[serde(rename = "orgId", skip_serializing_if = "Option::is_none")] + pub org_id: Option, + #[serde(rename = "globalPermissions", skip_serializing_if = "Option::is_none")] + pub global_permissions: Option>, + /// Display Name + #[serde(rename = "displayName", skip_serializing_if = "Option::is_none")] + pub display_name: Option, + /// User email address + #[serde(rename = "email", skip_serializing_if = "Option::is_none")] + pub email: Option, + #[serde(rename = "auth", skip_serializing_if = "Option::is_none")] + pub auth: Option>, + /// SMS number + #[serde(rename = "smsNumber", skip_serializing_if = "Option::is_none")] + pub sms_number: Option, + /// List of API token names. + #[serde(rename = "tokens", skip_serializing_if = "Option::is_none")] + pub tokens: Option>, +} + +impl User { + pub fn new() -> User { + User { + id: None, + org_id: None, + global_permissions: None, + display_name: None, + email: None, + auth: None, + sms_number: None, + tokens: None, + } + } +} + + diff --git a/zerotier-one-api/.gitignore b/zerotier-one-api/.gitignore new file mode 100644 index 0000000..6aa1064 --- /dev/null +++ b/zerotier-one-api/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/zerotier-one-api/.openapi-generator-ignore b/zerotier-one-api/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/zerotier-one-api/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/zerotier-one-api/.openapi-generator/FILES b/zerotier-one-api/.openapi-generator/FILES new file mode 100644 index 0000000..95fbdf4 --- /dev/null +++ b/zerotier-one-api/.openapi-generator/FILES @@ -0,0 +1,36 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +Cargo.toml +README.md +docs/Network.md +docs/NetworkAllOf.md +docs/NetworkAllOf1.md +docs/NetworkAllOf1Dns.md +docs/NetworkAllOf1MulticastSubscriptions.md +docs/NetworkApi.md +docs/Peer.md +docs/PeerApi.md +docs/PeerPaths.md +docs/Status.md +docs/StatusApi.md +docs/StatusConfig.md +docs/StatusConfigSettings.md +git_push.sh +src/apis/configuration.rs +src/apis/mod.rs +src/apis/network_api.rs +src/apis/peer_api.rs +src/apis/status_api.rs +src/lib.rs +src/models/mod.rs +src/models/network.rs +src/models/network_all_of.rs +src/models/network_all_of_1.rs +src/models/network_all_of_1_dns.rs +src/models/network_all_of_1_multicast_subscriptions.rs +src/models/peer.rs +src/models/peer_paths.rs +src/models/status.rs +src/models/status_config.rs +src/models/status_config_settings.rs diff --git a/zerotier-one-api/.openapi-generator/VERSION b/zerotier-one-api/.openapi-generator/VERSION new file mode 100644 index 0000000..6555596 --- /dev/null +++ b/zerotier-one-api/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.2.0-SNAPSHOT \ No newline at end of file diff --git a/zerotier-one-api/.travis.yml b/zerotier-one-api/.travis.yml new file mode 100644 index 0000000..22761ba --- /dev/null +++ b/zerotier-one-api/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/zerotier-one-api/Cargo.toml b/zerotier-one-api/Cargo.toml new file mode 100644 index 0000000..1808ab6 --- /dev/null +++ b/zerotier-one-api/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "zerotier-one-api" +version = "1.0.1" +edition = "2018" +description = "OpenAPI bindings to zerotier-one service" +authors = ["Erik Hollensbe ", "Adam Ierymenko "] +license = "BSD-3-Clause" + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "^2.2" +[dependencies.reqwest] +version = "^0.11" +default-features = false +features = ["json", "multipart"] + +[dev-dependencies] diff --git a/zerotier-one-api/README.md b/zerotier-one-api/README.md new file mode 100644 index 0000000..21399f8 --- /dev/null +++ b/zerotier-one-api/README.md @@ -0,0 +1,59 @@ +# Rust API client for zerotier-one-api + +

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 0.1.0 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.RustClientCodegen + +## Installation + +Put the package under your project folder and add the following to `Cargo.toml` under `[dependencies]`: + +``` + openapi = { path = "./generated" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost:9993* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*NetworkApi* | [**delete_network**](docs/NetworkApi.md#delete_network) | **delete** /network/{networkID} | Leave a network +*NetworkApi* | [**get_network**](docs/NetworkApi.md#get_network) | **get** /network/{networkID} | Gets a joined Network by ID. +*NetworkApi* | [**get_networks**](docs/NetworkApi.md#get_networks) | **get** /network | Get all network memberships. +*NetworkApi* | [**update_network**](docs/NetworkApi.md#update_network) | **post** /network/{networkID} | Join a network or update it's configuration +*PeerApi* | [**get_peer**](docs/PeerApi.md#get_peer) | **get** /peer/{address} | Get information about a specific peer. +*PeerApi* | [**get_peers**](docs/PeerApi.md#get_peers) | **get** /peer | Get all peers. +*StatusApi* | [**get_status**](docs/StatusApi.md#get_status) | **get** /status | Node status and addressing info. + + +## Documentation For Models + + - [Network](docs/Network.md) + - [NetworkAllOf](docs/NetworkAllOf.md) + - [NetworkAllOf1](docs/NetworkAllOf1.md) + - [NetworkAllOf1Dns](docs/NetworkAllOf1Dns.md) + - [NetworkAllOf1MulticastSubscriptions](docs/NetworkAllOf1MulticastSubscriptions.md) + - [Peer](docs/Peer.md) + - [PeerPaths](docs/PeerPaths.md) + - [Status](docs/Status.md) + - [StatusConfig](docs/StatusConfig.md) + - [StatusConfigSettings](docs/StatusConfigSettings.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + + + diff --git a/zerotier-one-api/docs/Network.md b/zerotier-one-api/docs/Network.md new file mode 100644 index 0000000..0a96609 --- /dev/null +++ b/zerotier-one-api/docs/Network.md @@ -0,0 +1,29 @@ +# Network + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**allow_dns** | Option<**bool**> | Let ZeroTier modify the system's DNS settings | [optional] +**allow_default** | Option<**bool**> | Let ZeroTier to modify the system's default route. | [optional] +**allow_global** | Option<**bool**> | Let ZeroTier to manage IP addresses and Route assignments that aren't in private ranges (rfc1918). | [optional] +**allow_managed** | Option<**bool**> | Let ZeroTier to manage IP addresses and Route assignments. | [optional] +**assigned_addresses** | Option<**Vec**> | | [optional] +**bridge** | Option<**bool**> | | [optional] +**broadcast_enabled** | Option<**bool**> | | [optional] +**dns** | Option<[**crate::models::NetworkAllOf1Dns**](Network_allOf_1_dns.md)> | | [optional] +**id** | Option<**String**> | | [optional] +**mac** | Option<**String**> | MAC address for this network's interface | [optional] +**mtu** | Option<**i32**> | | [optional] +**multicast_subscriptions** | Option<[**Vec**](Network_allOf_1_multicastSubscriptions.md)> | | [optional] +**name** | Option<**String**> | | [optional] +**netconf_revision** | Option<**i32**> | | [optional] +**port_device_name** | Option<**String**> | | [optional] +**port_error** | Option<**f32**> | | [optional] +**routes** | Option<[**Vec**](serde_json::Value.md)> | | [optional] +**status** | Option<**String**> | | [optional] +**_type** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/NetworkAllOf.md b/zerotier-one-api/docs/NetworkAllOf.md new file mode 100644 index 0000000..639fd23 --- /dev/null +++ b/zerotier-one-api/docs/NetworkAllOf.md @@ -0,0 +1,14 @@ +# NetworkAllOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**allow_dns** | Option<**bool**> | Let ZeroTier modify the system's DNS settings | [optional] +**allow_default** | Option<**bool**> | Let ZeroTier to modify the system's default route. | [optional] +**allow_global** | Option<**bool**> | Let ZeroTier to manage IP addresses and Route assignments that aren't in private ranges (rfc1918). | [optional] +**allow_managed** | Option<**bool**> | Let ZeroTier to manage IP addresses and Route assignments. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/NetworkAllOf1.md b/zerotier-one-api/docs/NetworkAllOf1.md new file mode 100644 index 0000000..c5b153d --- /dev/null +++ b/zerotier-one-api/docs/NetworkAllOf1.md @@ -0,0 +1,29 @@ +# NetworkAllOf1 + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**allow_dns** | Option<**bool**> | Let ZeroTier modify the system's DNS settings | [optional] +**allow_default** | Option<**bool**> | Let ZeroTier to modify the system's default route. | [optional] +**allow_global** | Option<**bool**> | Let ZeroTier to manage IP addresses and Route assignments that aren't in private ranges (rfc1918). | [optional] +**allow_managed** | Option<**bool**> | Let ZeroTier to manage IP addresses and Route assignments. | [optional] +**assigned_addresses** | Option<**Vec**> | | [optional] +**bridge** | Option<**bool**> | | [optional] +**broadcast_enabled** | Option<**bool**> | | [optional] +**dns** | Option<[**crate::models::NetworkAllOf1Dns**](Network_allOf_1_dns.md)> | | [optional] +**id** | Option<**String**> | | [optional] +**mac** | Option<**String**> | MAC address for this network's interface | [optional] +**mtu** | Option<**i32**> | | [optional] +**multicast_subscriptions** | Option<[**Vec**](Network_allOf_1_multicastSubscriptions.md)> | | [optional] +**name** | Option<**String**> | | [optional] +**netconf_revision** | Option<**i32**> | | [optional] +**port_device_name** | Option<**String**> | | [optional] +**port_error** | Option<**f32**> | | [optional] +**routes** | Option<[**Vec**](serde_json::Value.md)> | | [optional] +**status** | Option<**String**> | | [optional] +**_type** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/NetworkAllOf1Dns.md b/zerotier-one-api/docs/NetworkAllOf1Dns.md new file mode 100644 index 0000000..98c9d42 --- /dev/null +++ b/zerotier-one-api/docs/NetworkAllOf1Dns.md @@ -0,0 +1,12 @@ +# NetworkAllOf1Dns + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**domain** | Option<**String**> | | [optional] +**servers** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/NetworkAllOf1MulticastSubscriptions.md b/zerotier-one-api/docs/NetworkAllOf1MulticastSubscriptions.md new file mode 100644 index 0000000..142d79e --- /dev/null +++ b/zerotier-one-api/docs/NetworkAllOf1MulticastSubscriptions.md @@ -0,0 +1,12 @@ +# NetworkAllOf1MulticastSubscriptions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**adi** | Option<**f32**> | | [optional] +**mac** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/NetworkApi.md b/zerotier-one-api/docs/NetworkApi.md new file mode 100644 index 0000000..36bc742 --- /dev/null +++ b/zerotier-one-api/docs/NetworkApi.md @@ -0,0 +1,122 @@ +# \NetworkApi + +All URIs are relative to *http://localhost:9993* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_network**](NetworkApi.md#delete_network) | **delete** /network/{networkID} | Leave a network +[**get_network**](NetworkApi.md#get_network) | **get** /network/{networkID} | Gets a joined Network by ID. +[**get_networks**](NetworkApi.md#get_networks) | **get** /network | Get all network memberships. +[**update_network**](NetworkApi.md#update_network) | **post** /network/{networkID} | Join a network or update it's configuration + + + +## delete_network + +> delete_network(network_id) +Leave a network + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network | [required] | + +### Return type + + (empty response body) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_network + +> crate::models::Network get_network(network_id) +Gets a joined Network by ID. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network to change | [required] | + +### Return type + +[**crate::models::Network**](Network.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_networks + +> Vec get_networks() +Get all network memberships. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](Network.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_network + +> crate::models::Network update_network(network_id, network) +Join a network or update it's configuration + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**network_id** | **String** | ID of the network to change | [required] | +**network** | [**Network**](Network.md) | Network object JSON | [required] | + +### Return type + +[**crate::models::Network**](Network.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/zerotier-one-api/docs/Peer.md b/zerotier-one-api/docs/Peer.md new file mode 100644 index 0000000..b9a72f6 --- /dev/null +++ b/zerotier-one-api/docs/Peer.md @@ -0,0 +1,19 @@ +# Peer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**address** | Option<**String**> | | [optional] +**is_bonded** | Option<**bool**> | | [optional] +**latency** | Option<**i32**> | | [optional] +**paths** | Option<[**Vec**](Peer_paths.md)> | | [optional] +**role** | Option<**String**> | | [optional] +**version** | Option<**String**> | | [optional] +**version_major** | Option<**i32**> | | [optional] +**version_minor** | Option<**i32**> | | [optional] +**version_rev** | Option<**i32**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/PeerApi.md b/zerotier-one-api/docs/PeerApi.md new file mode 100644 index 0000000..57c8b83 --- /dev/null +++ b/zerotier-one-api/docs/PeerApi.md @@ -0,0 +1,63 @@ +# \PeerApi + +All URIs are relative to *http://localhost:9993* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_peer**](PeerApi.md#get_peer) | **get** /peer/{address} | Get information about a specific peer. +[**get_peers**](PeerApi.md#get_peers) | **get** /peer | Get all peers. + + + +## get_peer + +> crate::models::Peer get_peer(address) +Get information about a specific peer. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**address** | **String** | ZeroTier address of the peer | [required] | + +### Return type + +[**crate::models::Peer**](Peer.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_peers + +> Vec get_peers() +Get all peers. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](Peer.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/zerotier-one-api/docs/PeerPaths.md b/zerotier-one-api/docs/PeerPaths.md new file mode 100644 index 0000000..8a03b38 --- /dev/null +++ b/zerotier-one-api/docs/PeerPaths.md @@ -0,0 +1,17 @@ +# PeerPaths + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**active** | Option<**bool**> | | [optional] +**address** | Option<**String**> | | [optional] +**expired** | Option<**bool**> | | [optional] +**last_receive** | Option<**i32**> | | [optional] +**last_send** | Option<**i32**> | | [optional] +**preferred** | Option<**bool**> | | [optional] +**trusted_path_id** | Option<**i32**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/Status.md b/zerotier-one-api/docs/Status.md new file mode 100644 index 0000000..72a15de --- /dev/null +++ b/zerotier-one-api/docs/Status.md @@ -0,0 +1,23 @@ +# Status + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**address** | Option<**String**> | | [optional] +**clock** | Option<**f32**> | | [optional] +**config** | Option<[**crate::models::StatusConfig**](Status_config.md)> | | [optional] +**online** | Option<**bool**> | | [optional] +**planet_world_id** | Option<**f32**> | | [optional] +**planet_world_timestamp** | Option<**f32**> | | [optional] +**public_identity** | Option<**String**> | | [optional] +**tcp_fallback_active** | Option<**bool**> | | [optional] +**version** | Option<**String**> | | [optional] +**version_build** | Option<**i32**> | | [optional] +**version_major** | Option<**i32**> | | [optional] +**version_minor** | Option<**i32**> | | [optional] +**version_rev** | Option<**i32**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/StatusApi.md b/zerotier-one-api/docs/StatusApi.md new file mode 100644 index 0000000..db9fad8 --- /dev/null +++ b/zerotier-one-api/docs/StatusApi.md @@ -0,0 +1,34 @@ +# \StatusApi + +All URIs are relative to *http://localhost:9993* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_status**](StatusApi.md#get_status) | **get** /status | Node status and addressing info. + + + +## get_status + +> crate::models::Status get_status() +Node status and addressing info. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::Status**](Status.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/zerotier-one-api/docs/StatusConfig.md b/zerotier-one-api/docs/StatusConfig.md new file mode 100644 index 0000000..d126f98 --- /dev/null +++ b/zerotier-one-api/docs/StatusConfig.md @@ -0,0 +1,11 @@ +# StatusConfig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**settings** | Option<[**crate::models::StatusConfigSettings**](Status_config_settings.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/docs/StatusConfigSettings.md b/zerotier-one-api/docs/StatusConfigSettings.md new file mode 100644 index 0000000..0a03e7d --- /dev/null +++ b/zerotier-one-api/docs/StatusConfigSettings.md @@ -0,0 +1,13 @@ +# StatusConfigSettings + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**allow_tcp_fallback_relay** | Option<**bool**> | | [optional] +**port_mapping_enabled** | Option<**bool**> | | [optional] +**primary_port** | Option<**i32**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/zerotier-one-api/git_push.sh b/zerotier-one-api/git_push.sh new file mode 100644 index 0000000..ced3be2 --- /dev/null +++ b/zerotier-one-api/git_push.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/zerotier-one-api/src/apis/configuration.rs b/zerotier-one-api/src/apis/configuration.rs new file mode 100644 index 0000000..e2d5fb0 --- /dev/null +++ b/zerotier-one-api/src/apis/configuration.rs @@ -0,0 +1,52 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "http://localhost:9993".to_owned(), + user_agent: Some("OpenAPI-Generator/0.1.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/zerotier-one-api/src/apis/mod.rs b/zerotier-one-api/src/apis/mod.rs new file mode 100644 index 0000000..9da2787 --- /dev/null +++ b/zerotier-one-api/src/apis/mod.rs @@ -0,0 +1,68 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub mod network_api; +pub mod peer_api; +pub mod status_api; + +pub mod configuration; diff --git a/zerotier-one-api/src/apis/network_api.rs b/zerotier-one-api/src/apis/network_api.rs new file mode 100644 index 0000000..971c3c9 --- /dev/null +++ b/zerotier-one-api/src/apis/network_api.rs @@ -0,0 +1,187 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method `delete_network` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteNetworkError { + Status401(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_network` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNetworkError { + Status401(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_networks` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNetworksError { + Status401(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `update_network` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateNetworkError { + Status401(), + UnknownValue(serde_json::Value), +} + + +pub async fn delete_network(configuration: &configuration::Configuration, network_id: &str) -> Result<(), Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}", configuration.base_path, networkID=crate::apis::urlencode(network_id)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("X-ZT1-Auth", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_network(configuration: &configuration::Configuration, network_id: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}", configuration.base_path, networkID=crate::apis::urlencode(network_id)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("X-ZT1-Auth", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_networks(configuration: &configuration::Configuration, ) -> Result, Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("X-ZT1-Auth", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn update_network(configuration: &configuration::Configuration, network_id: &str, network: crate::models::Network) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/network/{networkID}", configuration.base_path, networkID=crate::apis::urlencode(network_id)); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("X-ZT1-Auth", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&network); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/zerotier-one-api/src/apis/peer_api.rs b/zerotier-one-api/src/apis/peer_api.rs new file mode 100644 index 0000000..626a053 --- /dev/null +++ b/zerotier-one-api/src/apis/peer_api.rs @@ -0,0 +1,102 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method `get_peer` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPeerError { + Status401(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method `get_peers` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPeersError { + Status401(), + UnknownValue(serde_json::Value), +} + + +pub async fn get_peer(configuration: &configuration::Configuration, address: &str) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/peer/{address}", configuration.base_path, address=crate::apis::urlencode(address)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("X-ZT1-Auth", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_peers(configuration: &configuration::Configuration, ) -> Result, Error> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/peer", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("X-ZT1-Auth", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/zerotier-one-api/src/apis/status_api.rs b/zerotier-one-api/src/apis/status_api.rs new file mode 100644 index 0000000..036a415 --- /dev/null +++ b/zerotier-one-api/src/apis/status_api.rs @@ -0,0 +1,60 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method `get_status` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetStatusError { + Status401(), + UnknownValue(serde_json::Value), +} + + +pub async fn get_status(configuration: &configuration::Configuration, ) -> Result> { + + let local_var_client = &configuration.client; + + let local_var_uri_str = format!("{}/status", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("X-ZT1-Auth", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/zerotier-one-api/src/lib.rs b/zerotier-one-api/src/lib.rs new file mode 100644 index 0000000..c1dd666 --- /dev/null +++ b/zerotier-one-api/src/lib.rs @@ -0,0 +1,10 @@ +#[macro_use] +extern crate serde_derive; + +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/zerotier-one-api/src/models/mod.rs b/zerotier-one-api/src/models/mod.rs new file mode 100644 index 0000000..6a26239 --- /dev/null +++ b/zerotier-one-api/src/models/mod.rs @@ -0,0 +1,20 @@ +pub mod network; +pub use self::network::Network; +pub mod network_all_of; +pub use self::network_all_of::NetworkAllOf; +pub mod network_all_of_1; +pub use self::network_all_of_1::NetworkAllOf1; +pub mod network_all_of_1_dns; +pub use self::network_all_of_1_dns::NetworkAllOf1Dns; +pub mod network_all_of_1_multicast_subscriptions; +pub use self::network_all_of_1_multicast_subscriptions::NetworkAllOf1MulticastSubscriptions; +pub mod peer; +pub use self::peer::Peer; +pub mod peer_paths; +pub use self::peer_paths::PeerPaths; +pub mod status; +pub use self::status::Status; +pub mod status_config; +pub use self::status_config::StatusConfig; +pub mod status_config_settings; +pub use self::status_config_settings::StatusConfigSettings; diff --git a/zerotier-one-api/src/models/network.rs b/zerotier-one-api/src/models/network.rs new file mode 100644 index 0000000..05bf4e6 --- /dev/null +++ b/zerotier-one-api/src/models/network.rs @@ -0,0 +1,87 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Network { + /// Let ZeroTier modify the system's DNS settings + #[serde(rename = "allowDNS", skip_serializing_if = "Option::is_none")] + pub allow_dns: Option, + /// Let ZeroTier to modify the system's default route. + #[serde(rename = "allowDefault", skip_serializing_if = "Option::is_none")] + pub allow_default: Option, + /// Let ZeroTier to manage IP addresses and Route assignments that aren't in private ranges (rfc1918). + #[serde(rename = "allowGlobal", skip_serializing_if = "Option::is_none")] + pub allow_global: Option, + /// Let ZeroTier to manage IP addresses and Route assignments. + #[serde(rename = "allowManaged", skip_serializing_if = "Option::is_none")] + pub allow_managed: Option, + #[serde(rename = "assignedAddresses", skip_serializing_if = "Option::is_none")] + pub assigned_addresses: Option>, + #[serde(rename = "bridge", skip_serializing_if = "Option::is_none")] + pub bridge: Option, + #[serde(rename = "broadcastEnabled", skip_serializing_if = "Option::is_none")] + pub broadcast_enabled: Option, + #[serde(rename = "dns", skip_serializing_if = "Option::is_none")] + pub dns: Option>, + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// MAC address for this network's interface + #[serde(rename = "mac", skip_serializing_if = "Option::is_none")] + pub mac: Option, + #[serde(rename = "mtu", skip_serializing_if = "Option::is_none")] + pub mtu: Option, + #[serde(rename = "multicastSubscriptions", skip_serializing_if = "Option::is_none")] + pub multicast_subscriptions: Option>, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(rename = "netconfRevision", skip_serializing_if = "Option::is_none")] + pub netconf_revision: Option, + #[serde(rename = "portDeviceName", skip_serializing_if = "Option::is_none")] + pub port_device_name: Option, + #[serde(rename = "portError", skip_serializing_if = "Option::is_none")] + pub port_error: Option, + #[serde(rename = "routes", skip_serializing_if = "Option::is_none")] + pub routes: Option>, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub _type: Option, +} + +impl Network { + pub fn new() -> Network { + Network { + allow_dns: None, + allow_default: None, + allow_global: None, + allow_managed: None, + assigned_addresses: None, + bridge: None, + broadcast_enabled: None, + dns: None, + id: None, + mac: None, + mtu: None, + multicast_subscriptions: None, + name: None, + netconf_revision: None, + port_device_name: None, + port_error: None, + routes: None, + status: None, + _type: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/network_all_of.rs b/zerotier-one-api/src/models/network_all_of.rs new file mode 100644 index 0000000..a65338b --- /dev/null +++ b/zerotier-one-api/src/models/network_all_of.rs @@ -0,0 +1,41 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct NetworkAllOf { + /// Let ZeroTier modify the system's DNS settings + #[serde(rename = "allowDNS", skip_serializing_if = "Option::is_none")] + pub allow_dns: Option, + /// Let ZeroTier to modify the system's default route. + #[serde(rename = "allowDefault", skip_serializing_if = "Option::is_none")] + pub allow_default: Option, + /// Let ZeroTier to manage IP addresses and Route assignments that aren't in private ranges (rfc1918). + #[serde(rename = "allowGlobal", skip_serializing_if = "Option::is_none")] + pub allow_global: Option, + /// Let ZeroTier to manage IP addresses and Route assignments. + #[serde(rename = "allowManaged", skip_serializing_if = "Option::is_none")] + pub allow_managed: Option, +} + +impl NetworkAllOf { + pub fn new() -> NetworkAllOf { + NetworkAllOf { + allow_dns: None, + allow_default: None, + allow_global: None, + allow_managed: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/network_all_of_1.rs b/zerotier-one-api/src/models/network_all_of_1.rs new file mode 100644 index 0000000..c60cf0d --- /dev/null +++ b/zerotier-one-api/src/models/network_all_of_1.rs @@ -0,0 +1,87 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct NetworkAllOf1 { + /// Let ZeroTier modify the system's DNS settings + #[serde(rename = "allowDNS", skip_serializing_if = "Option::is_none")] + pub allow_dns: Option, + /// Let ZeroTier to modify the system's default route. + #[serde(rename = "allowDefault", skip_serializing_if = "Option::is_none")] + pub allow_default: Option, + /// Let ZeroTier to manage IP addresses and Route assignments that aren't in private ranges (rfc1918). + #[serde(rename = "allowGlobal", skip_serializing_if = "Option::is_none")] + pub allow_global: Option, + /// Let ZeroTier to manage IP addresses and Route assignments. + #[serde(rename = "allowManaged", skip_serializing_if = "Option::is_none")] + pub allow_managed: Option, + #[serde(rename = "assignedAddresses", skip_serializing_if = "Option::is_none")] + pub assigned_addresses: Option>, + #[serde(rename = "bridge", skip_serializing_if = "Option::is_none")] + pub bridge: Option, + #[serde(rename = "broadcastEnabled", skip_serializing_if = "Option::is_none")] + pub broadcast_enabled: Option, + #[serde(rename = "dns", skip_serializing_if = "Option::is_none")] + pub dns: Option>, + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// MAC address for this network's interface + #[serde(rename = "mac", skip_serializing_if = "Option::is_none")] + pub mac: Option, + #[serde(rename = "mtu", skip_serializing_if = "Option::is_none")] + pub mtu: Option, + #[serde(rename = "multicastSubscriptions", skip_serializing_if = "Option::is_none")] + pub multicast_subscriptions: Option>, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(rename = "netconfRevision", skip_serializing_if = "Option::is_none")] + pub netconf_revision: Option, + #[serde(rename = "portDeviceName", skip_serializing_if = "Option::is_none")] + pub port_device_name: Option, + #[serde(rename = "portError", skip_serializing_if = "Option::is_none")] + pub port_error: Option, + #[serde(rename = "routes", skip_serializing_if = "Option::is_none")] + pub routes: Option>, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub _type: Option, +} + +impl NetworkAllOf1 { + pub fn new() -> NetworkAllOf1 { + NetworkAllOf1 { + allow_dns: None, + allow_default: None, + allow_global: None, + allow_managed: None, + assigned_addresses: None, + bridge: None, + broadcast_enabled: None, + dns: None, + id: None, + mac: None, + mtu: None, + multicast_subscriptions: None, + name: None, + netconf_revision: None, + port_device_name: None, + port_error: None, + routes: None, + status: None, + _type: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/network_all_of_1_dns.rs b/zerotier-one-api/src/models/network_all_of_1_dns.rs new file mode 100644 index 0000000..9010c93 --- /dev/null +++ b/zerotier-one-api/src/models/network_all_of_1_dns.rs @@ -0,0 +1,31 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct NetworkAllOf1Dns { + #[serde(rename = "domain", skip_serializing_if = "Option::is_none")] + pub domain: Option, + #[serde(rename = "servers", skip_serializing_if = "Option::is_none")] + pub servers: Option>, +} + +impl NetworkAllOf1Dns { + pub fn new() -> NetworkAllOf1Dns { + NetworkAllOf1Dns { + domain: None, + servers: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/network_all_of_1_multicast_subscriptions.rs b/zerotier-one-api/src/models/network_all_of_1_multicast_subscriptions.rs new file mode 100644 index 0000000..9ef7bf3 --- /dev/null +++ b/zerotier-one-api/src/models/network_all_of_1_multicast_subscriptions.rs @@ -0,0 +1,31 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct NetworkAllOf1MulticastSubscriptions { + #[serde(rename = "adi", skip_serializing_if = "Option::is_none")] + pub adi: Option, + #[serde(rename = "mac", skip_serializing_if = "Option::is_none")] + pub mac: Option, +} + +impl NetworkAllOf1MulticastSubscriptions { + pub fn new() -> NetworkAllOf1MulticastSubscriptions { + NetworkAllOf1MulticastSubscriptions { + adi: None, + mac: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/peer.rs b/zerotier-one-api/src/models/peer.rs new file mode 100644 index 0000000..9c6ae75 --- /dev/null +++ b/zerotier-one-api/src/models/peer.rs @@ -0,0 +1,52 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Peer { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde(rename = "isBonded", skip_serializing_if = "Option::is_none")] + pub is_bonded: Option, + #[serde(rename = "latency", skip_serializing_if = "Option::is_none")] + pub latency: Option, + #[serde(rename = "paths", skip_serializing_if = "Option::is_none")] + pub paths: Option>, + #[serde(rename = "role", skip_serializing_if = "Option::is_none")] + pub role: Option, + #[serde(rename = "version", skip_serializing_if = "Option::is_none")] + pub version: Option, + #[serde(rename = "versionMajor", skip_serializing_if = "Option::is_none")] + pub version_major: Option, + #[serde(rename = "versionMinor", skip_serializing_if = "Option::is_none")] + pub version_minor: Option, + #[serde(rename = "versionRev", skip_serializing_if = "Option::is_none")] + pub version_rev: Option, +} + +impl Peer { + pub fn new() -> Peer { + Peer { + address: None, + is_bonded: None, + latency: None, + paths: None, + role: None, + version: None, + version_major: None, + version_minor: None, + version_rev: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/peer_paths.rs b/zerotier-one-api/src/models/peer_paths.rs new file mode 100644 index 0000000..9e936d0 --- /dev/null +++ b/zerotier-one-api/src/models/peer_paths.rs @@ -0,0 +1,46 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct PeerPaths { + #[serde(rename = "active", skip_serializing_if = "Option::is_none")] + pub active: Option, + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde(rename = "expired", skip_serializing_if = "Option::is_none")] + pub expired: Option, + #[serde(rename = "lastReceive", skip_serializing_if = "Option::is_none")] + pub last_receive: Option, + #[serde(rename = "lastSend", skip_serializing_if = "Option::is_none")] + pub last_send: Option, + #[serde(rename = "preferred", skip_serializing_if = "Option::is_none")] + pub preferred: Option, + #[serde(rename = "trustedPathId", skip_serializing_if = "Option::is_none")] + pub trusted_path_id: Option, +} + +impl PeerPaths { + pub fn new() -> PeerPaths { + PeerPaths { + active: None, + address: None, + expired: None, + last_receive: None, + last_send: None, + preferred: None, + trusted_path_id: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/status.rs b/zerotier-one-api/src/models/status.rs new file mode 100644 index 0000000..6230133 --- /dev/null +++ b/zerotier-one-api/src/models/status.rs @@ -0,0 +1,64 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Status { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde(rename = "clock", skip_serializing_if = "Option::is_none")] + pub clock: Option, + #[serde(rename = "config", skip_serializing_if = "Option::is_none")] + pub config: Option>, + #[serde(rename = "online", skip_serializing_if = "Option::is_none")] + pub online: Option, + #[serde(rename = "planetWorldId", skip_serializing_if = "Option::is_none")] + pub planet_world_id: Option, + #[serde(rename = "planetWorldTimestamp", skip_serializing_if = "Option::is_none")] + pub planet_world_timestamp: Option, + #[serde(rename = "publicIdentity", skip_serializing_if = "Option::is_none")] + pub public_identity: Option, + #[serde(rename = "tcpFallbackActive", skip_serializing_if = "Option::is_none")] + pub tcp_fallback_active: Option, + #[serde(rename = "version", skip_serializing_if = "Option::is_none")] + pub version: Option, + #[serde(rename = "versionBuild", skip_serializing_if = "Option::is_none")] + pub version_build: Option, + #[serde(rename = "versionMajor", skip_serializing_if = "Option::is_none")] + pub version_major: Option, + #[serde(rename = "versionMinor", skip_serializing_if = "Option::is_none")] + pub version_minor: Option, + #[serde(rename = "versionRev", skip_serializing_if = "Option::is_none")] + pub version_rev: Option, +} + +impl Status { + pub fn new() -> Status { + Status { + address: None, + clock: None, + config: None, + online: None, + planet_world_id: None, + planet_world_timestamp: None, + public_identity: None, + tcp_fallback_active: None, + version: None, + version_build: None, + version_major: None, + version_minor: None, + version_rev: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/status_config.rs b/zerotier-one-api/src/models/status_config.rs new file mode 100644 index 0000000..0c57828 --- /dev/null +++ b/zerotier-one-api/src/models/status_config.rs @@ -0,0 +1,28 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct StatusConfig { + #[serde(rename = "settings", skip_serializing_if = "Option::is_none")] + pub settings: Option>, +} + +impl StatusConfig { + pub fn new() -> StatusConfig { + StatusConfig { + settings: None, + } + } +} + + diff --git a/zerotier-one-api/src/models/status_config_settings.rs b/zerotier-one-api/src/models/status_config_settings.rs new file mode 100644 index 0000000..ac83fd3 --- /dev/null +++ b/zerotier-one-api/src/models/status_config_settings.rs @@ -0,0 +1,34 @@ +/* + * ZeroTierOne Service API + * + *

This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service.

API requests must be authenticated via an authentication token. ZeroTier One saves this token in the authtoken.secret file in its working directory. This token may be supplied via the X-ZT1-Auth HTTP request header.

For example: curl -H \"X-ZT1-Auth: $TOKEN\" http://localhost:9993/status

The token can be found in:

  • Mac :: /Library/Application Support/ZeroTier/One
  • Windows :: \\ProgramData\\ZeroTier\\One
  • Linux :: /var/lib/zerotier-one

+ * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct StatusConfigSettings { + #[serde(rename = "allowTcpFallbackRelay", skip_serializing_if = "Option::is_none")] + pub allow_tcp_fallback_relay: Option, + #[serde(rename = "portMappingEnabled", skip_serializing_if = "Option::is_none")] + pub port_mapping_enabled: Option, + #[serde(rename = "primaryPort", skip_serializing_if = "Option::is_none")] + pub primary_port: Option, +} + +impl StatusConfigSettings { + pub fn new() -> StatusConfigSettings { + StatusConfigSettings { + allow_tcp_fallback_relay: None, + port_mapping_enabled: None, + primary_port: None, + } + } +} + +