Skip to content

Commit 25ce13c

Browse files
committed
feat(oauth): add generated API
1 parent fade4ae commit 25ce13c

File tree

22 files changed

+8580
-3
lines changed

22 files changed

+8580
-3
lines changed

src/extension/host-binary/Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ post-gen-go-client:
7272
./pkg/generated/go/client/$(DD_API_NAME)/go.* \
7373
./pkg/generated/go/client/$(DD_API_NAME)/git_push.sh
7474

75-
generate: DD_API_NAME=secrets
76-
generate: DD_API_PKGNAME=secretsapi
77-
generate: pre-gen-clients gen-go-client gen-ts-client gen-secrets-api-html post-gen-go-client
75+
generate-sm: DD_API_NAME=secrets
76+
generate-sm: DD_API_PKGNAME=secretsapi
77+
generate-sm: pre-gen-clients gen-go-client gen-secrets-api-html post-gen-go-client
78+
79+
generate-oauth: DD_API_NAME=tools
80+
generate-oauth: DD_API_PKGNAME=oauthapi
81+
generate-oauth: pre-gen-clients gen-go-client gen-secrets-api-html post-gen-go-client
82+
83+
generate: generate-sm generate-oauth
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
openapi: 3.0.3
2+
info:
3+
version: 0.0.0
4+
title: Docker Desktop tools API
5+
x-redocly-package-name: tools
6+
tags:
7+
- name: tools
8+
paths:
9+
/apps:
10+
get:
11+
summary: Lists all app objects.
12+
tags: [ tools ]
13+
operationId: listOAuthApps
14+
responses:
15+
'200':
16+
description: success
17+
content:
18+
application/json:
19+
schema:
20+
type: array
21+
items:
22+
$ref: '#/components/schemas/OAuthApp'
23+
'500':
24+
description: unexpected error
25+
/apps/{app}:
26+
post:
27+
summary: Authorize an app.
28+
tags: [ tools ]
29+
operationId: postOAuthApp
30+
parameters:
31+
- name: app
32+
in: path
33+
required: true
34+
schema:
35+
type: string
36+
- name: scopes
37+
in: query
38+
required: false
39+
schema:
40+
type: string
41+
responses:
42+
'200':
43+
description: success
44+
content:
45+
application/json:
46+
schema:
47+
$ref: '#/components/schemas/AuthResponse'
48+
'500':
49+
description: unexpected error
50+
content:
51+
application/json:
52+
schema:
53+
$ref: '#/components/schemas/AuthResponse'
54+
get:
55+
summary: Returns an app object.
56+
tags: [ tools ]
57+
operationId: getOAuthApp
58+
parameters:
59+
- name: app
60+
in: path
61+
required: true
62+
schema:
63+
type: string
64+
responses:
65+
'200':
66+
description: success
67+
content:
68+
application/json:
69+
schema:
70+
$ref: '#/components/schemas/OAuthApp'
71+
'500':
72+
description: unexpected error
73+
delete:
74+
summary: Unauthorizes an app.
75+
tags: [ tools ]
76+
operationId: deleteOAuthApp
77+
parameters:
78+
- name: app
79+
in: path
80+
required: true
81+
schema:
82+
type: string
83+
responses:
84+
'200':
85+
description: success
86+
'500':
87+
description: unexpected error
88+
/apps/{app}/tools/{tool}:
89+
post:
90+
summary: Add a tool to an app.
91+
tags: [ tools ]
92+
operationId: postOAuthAppTool
93+
parameters:
94+
- name: app
95+
in: path
96+
required: true
97+
schema:
98+
type: string
99+
- name: tool
100+
in: path
101+
required: true
102+
schema:
103+
type: string
104+
responses:
105+
'200':
106+
description: success
107+
'500':
108+
description: unexpected error
109+
delete:
110+
summary: Remove a tool from an app.
111+
tags: [ tools ]
112+
operationId: deleteOAuthAppTool
113+
parameters:
114+
- name: app
115+
in: path
116+
required: true
117+
schema:
118+
type: string
119+
- name: tool
120+
in: path
121+
required: true
122+
schema:
123+
type: string
124+
responses:
125+
'200':
126+
description: success
127+
'500':
128+
description: unexpected error
129+
components:
130+
schemas:
131+
OAuthScopes:
132+
type: object
133+
properties:
134+
name:
135+
type: string
136+
description:
137+
type: string
138+
metadata:
139+
type: array
140+
items:
141+
type: string
142+
OAuthApp:
143+
type: object
144+
properties:
145+
app:
146+
type: string
147+
tools:
148+
type: array
149+
items:
150+
type: string
151+
authorized:
152+
type: boolean
153+
provider:
154+
type: string
155+
scopes:
156+
type: array
157+
items:
158+
$ref: '#/components/schemas/OAuthScopes'
159+
required:
160+
- app
161+
- tools
162+
- authorized
163+
- provider
164+
AuthResponse:
165+
type: object
166+
properties:
167+
browserUrl:
168+
type: string
169+
authType:
170+
type: string
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.gitignore
2+
.openapi-generator-ignore
3+
.travis.yml
4+
README.md
5+
api/openapi.yaml
6+
api_tools.go
7+
client.go
8+
configuration.go
9+
docs/AuthResponse.md
10+
docs/OAuthApp.md
11+
docs/OAuthScopes.md
12+
docs/ToolsApi.md
13+
git_push.sh
14+
go.mod
15+
go.sum
16+
model_auth_response.go
17+
model_o_auth_app.go
18+
model_o_auth_scopes.go
19+
response.go
20+
utils.go
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.1.0-SNAPSHOT
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Go API client for oauthapi
2+
3+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4+
5+
## Overview
6+
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
7+
8+
- API version: 0.0.0
9+
- Package version: 1.0.0
10+
- Build package: org.openapitools.codegen.languages.GoClientCodegen
11+
12+
## Installation
13+
14+
Install the following dependencies:
15+
16+
```shell
17+
go get github.com/stretchr/testify/assert
18+
go get golang.org/x/oauth2
19+
go get golang.org/x/net/context
20+
```
21+
22+
Put the package under your project folder and add the following in import:
23+
24+
```golang
25+
import oauthapi "github.com/GIT_USER_ID/GIT_REPO_ID"
26+
```
27+
28+
To use a proxy, set the environment variable `HTTP_PROXY`:
29+
30+
```golang
31+
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
32+
```
33+
34+
## Configuration of Server URL
35+
36+
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
37+
38+
### Select Server Configuration
39+
40+
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
41+
42+
```golang
43+
ctx := context.WithValue(context.Background(), oauthapi.ContextServerIndex, 1)
44+
```
45+
46+
### Templated Server URL
47+
48+
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
49+
50+
```golang
51+
ctx := context.WithValue(context.Background(), oauthapi.ContextServerVariables, map[string]string{
52+
"basePath": "v2",
53+
})
54+
```
55+
56+
Note, enum values are always validated and all unused variables are silently ignored.
57+
58+
### URLs Configuration per Operation
59+
60+
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
61+
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
62+
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
63+
64+
```
65+
ctx := context.WithValue(context.Background(), oauthapi.ContextOperationServerIndices, map[string]int{
66+
"{classname}Service.{nickname}": 2,
67+
})
68+
ctx = context.WithValue(context.Background(), oauthapi.ContextOperationServerVariables, map[string]map[string]string{
69+
"{classname}Service.{nickname}": {
70+
"port": "8443",
71+
},
72+
})
73+
```
74+
75+
## Documentation for API Endpoints
76+
77+
All URIs are relative to *http://localhost*
78+
79+
Class | Method | HTTP request | Description
80+
------------ | ------------- | ------------- | -------------
81+
*ToolsApi* | [**DeleteOAuthApp**](docs/ToolsApi.md#deleteoauthapp) | **Delete** /apps/{app} | Unauthorizes an app.
82+
*ToolsApi* | [**DeleteOAuthAppTool**](docs/ToolsApi.md#deleteoauthapptool) | **Delete** /apps/{app}/tools/{tool} | Remove a tool from an app.
83+
*ToolsApi* | [**GetOAuthApp**](docs/ToolsApi.md#getoauthapp) | **Get** /apps/{app} | Returns an app object.
84+
*ToolsApi* | [**ListOAuthApps**](docs/ToolsApi.md#listoauthapps) | **Get** /apps | Lists all app objects.
85+
*ToolsApi* | [**PostOAuthApp**](docs/ToolsApi.md#postoauthapp) | **Post** /apps/{app} | Authorize an app.
86+
*ToolsApi* | [**PostOAuthAppTool**](docs/ToolsApi.md#postoauthapptool) | **Post** /apps/{app}/tools/{tool} | Add a tool to an app.
87+
88+
89+
## Documentation For Models
90+
91+
- [AuthResponse](docs/AuthResponse.md)
92+
- [OAuthApp](docs/OAuthApp.md)
93+
- [OAuthScopes](docs/OAuthScopes.md)
94+
95+
96+
## Documentation For Authorization
97+
98+
Endpoints do not require authorization.
99+
100+
101+
## Documentation for Utility Methods
102+
103+
Due to the fact that model structure members are all pointers, this package contains
104+
a number of utility functions to easily obtain pointers to values of basic types.
105+
Each of these functions takes a value of the given basic type and returns a pointer to it:
106+
107+
* `PtrBool`
108+
* `PtrInt`
109+
* `PtrInt32`
110+
* `PtrInt64`
111+
* `PtrFloat`
112+
* `PtrFloat32`
113+
* `PtrFloat64`
114+
* `PtrString`
115+
* `PtrTime`
116+
117+
## Author
118+
119+
120+

0 commit comments

Comments
 (0)