Signed-off-by: Erik Hollensbe <linux@hollensbe.org>
This commit is contained in:
Erik Hollensbe
2021-07-28 14:07:13 -07:00
commit ba793acbe3
99 changed files with 4893 additions and 0 deletions
+26
View File
@@ -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.
+9
View File
@@ -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
+25
View File
@@ -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
+3
View File
@@ -0,0 +1,3 @@
/target/
**/*.rs.bk
Cargo.lock
@@ -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
@@ -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
@@ -0,0 +1 @@
5.2.0-SNAPSHOT
+1
View File
@@ -0,0 +1 @@
language: rust
+18
View File
@@ -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 <linux@hollensbe.org>", "Adam Ierymenko <adam.ierymenko@zerotier.com>"]
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]
+84
View File
@@ -0,0 +1,84 @@
# Rust API client for zerotier-central-api
ZeroTier Central Network Management Portal API.<p>All API requests must have an API token header specified in the <code>Authorization: Bearer xxxxx</code> format. You can generate your API key by logging into <a href=\"https://my.zerotier.com\">ZeroTier Central</a> and creating a token on the Account page.</p><p>eg. <code>curl -X GET -H \"Authorization: bearer xxxxx\" https://my.zerotier.com/api/network</code></p>
## 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
+12
View File
@@ -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)
+13
View File
@@ -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)
+10
View File
@@ -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)
+12
View File
@@ -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)
@@ -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)
@@ -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)
+24
View File
@@ -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)
+26
View File
@@ -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<i32>**> | | [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<String>**> | 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<Vec<i32>>**](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)
+22
View File
@@ -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<String, crate::models::Permissions>**](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)
+153
View File
@@ -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<crate::models::Network> get_network_list()
Returns a list of Networks you have access to.
### Parameters
This endpoint does not need any parameter.
### Return type
[**Vec<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)
## 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)

Some files were not shown because too many files have changed in this diff Show More