Skip to content

Commit 8b359dd

Browse files
authored
Merge pull request #6 from arash-r1c/main
Create auto-generated release
2 parents 01522e1 + 0988fe1 commit 8b359dd

37 files changed

+489
-2608
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @hatamiarash7
1+
* @arash-r1c

.github/dependabot.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ updates:
1010
reviewers:
1111
- "hatamiarash7"
1212

13-
- package-ecosystem: "docker"
14-
directory: "/"
15-
schedule:
16-
interval: "daily"
17-
assignees:
18-
- "hatamiarash7"
19-
reviewers:
20-
- "hatamiarash7"
21-
2213
- package-ecosystem: "gomod"
2314
directory: "/"
2415
schedule:

.github/generator/.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
2+
*.o
3+
*.a
4+
*.so
5+
6+
# Folders
7+
_obj
8+
_test
9+
10+
# Architecture specific extensions/prefixes
11+
*.[568vq]
12+
[568vq].out
13+
14+
# CGO
15+
*.cgo1.go
16+
*.cgo2.c
17+
_cgo_defun.c
18+
_cgo_gotypes.go
19+
_cgo_export.*
20+
21+
# Other
22+
_testmain.go
23+
*.exe
24+
*.test
25+
*.prof
26+
.DS_Store
27+
28+
# IDE
29+
.vscode
30+
31+
# Generator
32+
.openapi-generator-ignore
33+
.openapi-generator
34+
.travis.yml
35+
git_push.sh
File renamed without changes.
File renamed without changes.
File renamed without changes.

.github/generator/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ArvanCloud CDN Go
2+
3+
[![Release](https://github.com/arvancloud/cdn-go/actions/workflows/release.yaml/badge.svg)](https://github.com/arvancloud/cdn-go/actions/workflows/release.yaml) [![CodeQL](https://github.com/arvancloud/cdn-go/actions/workflows/codeql.yaml/badge.svg)](https://github.com/arvancloud/cdn-go/actions/workflows/codeql.yaml) ![Docker Image Size (latest semver)](https://img.shields.io/docker/image-size/r1cloud/cdn?sort=semver) ![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/arvancloud/cdn-go) ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/arvancloud/cdn-go?display_name=tag&label=version&sort=semver)
4+
5+
![logo](.github/logo.svg)
6+
7+
It's a Go library for interacting with the ArvanCloud CDN API.
8+
9+
## Installation
10+
11+
```bash
12+
go get github.com/arvancloud/cdn-go
13+
```
14+
15+
## Usage
16+
17+
Check the [HOW-TO.md](docs/HOW-TO.md) file for more information.
18+
19+
## Contributing
20+
21+
We welcome contributions from the community. Please report any issues you find in the [Issues page](https://github.com/arvancloud/cdn-go/issues) or send us an email at [[email protected]](mailto:[email protected]).
File renamed without changes.

.github/generator/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packageName: r1cdn
2+
generateInterfaces: false
3+
packageVersion: 1.0.0
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
# Go API client for {{packageName}}
2+
3+
Use this documentation to learn how to use the ArvanCloud SDK.
4+
5+
**API version**: {{appVersion}}
6+
7+
## Dependencies
8+
9+
Install the following packages:
10+
11+
```shell
12+
go get github.com/stretchr/testify/assert
13+
{{#hasOAuthMethods}}
14+
go get golang.org/x/oauth2
15+
{{/hasOAuthMethods}}
16+
go get golang.org/x/net/context
17+
```
18+
19+
## Usage
20+
21+
Get the package:
22+
23+
```bash
24+
go get github.com/arvancloud/cdn-go
25+
```
26+
27+
Put the package under your project folder and add the following in import:
28+
29+
```golang
30+
import {{packageName}} "github.com/arvancloud/cdn-go"
31+
```
32+
33+
## Configuration of Server URL
34+
35+
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
36+
37+
### Select Server Configuration
38+
39+
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
40+
41+
```golang
42+
ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerIndex, 1)
43+
```
44+
45+
### Templated Server URL
46+
47+
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
48+
49+
```golang
50+
ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerVariables, map[string]string{
51+
"basePath": "v2",
52+
})
53+
```
54+
55+
Note, enum values are always validated and all unused variables are silently ignored.
56+
57+
### URLs Configuration per Operation
58+
59+
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
60+
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
61+
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
62+
63+
```golang
64+
ctx := context.WithValue(context.Background(), {{packageName}}.ContextOperationServerIndices, map[string]int{
65+
"{classname}Service.{nickname}": 2,
66+
})
67+
ctx = context.WithValue(context.Background(), {{packageName}}.ContextOperationServerVariables, map[string]map[string]string{
68+
"{classname}Service.{nickname}": {
69+
"port": "8443",
70+
},
71+
})
72+
```
73+
74+
## Documentation for API Endpoints
75+
76+
All URIs are relative to *{{basePath}}*
77+
78+
Class | Method | HTTP request | Description
79+
------------ | ------------- | ------------- | -------------
80+
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
81+
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
82+
83+
## Documentation For Models
84+
85+
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
86+
{{/model}}{{/models}}
87+
88+
## Documentation For Authorization
89+
90+
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
91+
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
92+
{{#authMethods}}
93+
### {{{name}}}
94+
95+
{{#isApiKey}}
96+
- **Type**: API key
97+
- **API key parameter name**: {{{keyParamName}}}
98+
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
99+
100+
Note, each API key must be added to a map of `map[string]APIKey` where the key is: {{keyParamName}} and passed in as the auth context for each request.
101+
102+
Example
103+
104+
```golang
105+
auth := context.WithValue(
106+
context.Background(),
107+
sw.ContextAPIKeys,
108+
map[string]sw.APIKey{
109+
"{{keyParamName}}": {Key: "API_KEY_STRING"},
110+
},
111+
)
112+
r, err := client.Service.Operation(auth, args)
113+
```
114+
115+
{{/isApiKey}}
116+
{{#isBasic}}
117+
{{#isBasicBearer}}
118+
- **Type**: HTTP Bearer token authentication
119+
120+
Example
121+
122+
```golang
123+
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
124+
r, err := client.Service.Operation(auth, args)
125+
```
126+
127+
{{/isBasicBearer}}
128+
{{#isBasicBasic}}
129+
- **Type**: HTTP basic authentication
130+
131+
Example
132+
133+
```golang
134+
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
135+
UserName: "username",
136+
Password: "password",
137+
})
138+
r, err := client.Service.Operation(auth, args)
139+
```
140+
141+
{{/isBasicBasic}}
142+
{{#isHttpSignature}}
143+
- **Type**: HTTP signature authentication
144+
145+
Example
146+
147+
```golang
148+
authConfig := client.HttpSignatureAuth{
149+
KeyId: "my-key-id",
150+
PrivateKeyPath: "rsa.pem",
151+
Passphrase: "my-passphrase",
152+
SigningScheme: sw.HttpSigningSchemeHs2019,
153+
SignedHeaders: []string{
154+
sw.HttpSignatureParameterRequestTarget, // The special (request-target) parameter expresses the HTTP request target.
155+
sw.HttpSignatureParameterCreated, // Time when request was signed, formatted as a Unix timestamp integer value.
156+
"Host", // The Host request header specifies the domain name of the server, and optionally the TCP port number.
157+
"Date", // The date and time at which the message was originated.
158+
"Content-Type", // The Media type of the body of the request.
159+
"Digest", // A cryptographic digest of the request body.
160+
},
161+
SigningAlgorithm: sw.HttpSigningAlgorithmRsaPSS,
162+
SignatureMaxValidity: 5 * time.Minute,
163+
}
164+
var authCtx context.Context
165+
var err error
166+
if authCtx, err = authConfig.ContextWithValue(context.Background()); err != nil {
167+
// Process error
168+
}
169+
r, err = client.Service.Operation(auth, args)
170+
171+
```
172+
{{/isHttpSignature}}
173+
{{/isBasic}}
174+
{{#isOAuth}}
175+
176+
- **Type**: OAuth
177+
- **Flow**: {{{flow}}}
178+
- **Authorization URL**: {{{authorizationUrl}}}
179+
- **Scopes**: {{^scopes}}N/A{{/scopes}}
180+
{{#scopes}} - **{{{scope}}}**: {{{description}}}
181+
{{/scopes}}
182+
183+
Example
184+
185+
```golang
186+
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
187+
r, err := client.Service.Operation(auth, args)
188+
```
189+
190+
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
191+
192+
```golang
193+
import "golang.org/x/oauth2"
194+
195+
/* Perform OAuth2 round trip request and obtain a token */
196+
197+
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
198+
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
199+
r, err := client.Service.Operation(auth, args)
200+
```
201+
202+
{{/isOAuth}}
203+
{{/authMethods}}
204+
205+
## Documentation for Utility Methods
206+
207+
Due to the fact that model structure members are all pointers, this package contains
208+
a number of utility functions to easily obtain pointers to values of basic types.
209+
Each of these functions takes a value of the given basic type and returns a pointer to it:
210+
211+
* `PtrBool`
212+
* `PtrInt`
213+
* `PtrInt32`
214+
* `PtrInt64`
215+
* `PtrFloat`
216+
* `PtrFloat32`
217+
* `PtrFloat64`
218+
* `PtrString`
219+
* `PtrTime`
220+
221+
## Author
222+
223+
{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
224+
{{/-last}}{{/apis}}{{/apiInfo}}

.github/generator/tune.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
cat .github/generator/.gitignore >>.gitignore
4+
mv README.md docs/HOW-TO.md
5+
cp .github/generator/*.md .
6+
sed -i 's/GIT_USER_ID/arvancloud/g' go.mod test/*.go docs/*.md
7+
sed -i 's/GIT_REPO_ID/cdn-go/g' go.mod test/*.go docs/*.md
8+
sed -i 's+(docs/+(+g' docs/*.md
9+
sed -i 's+../README.md#+HOW-TO.md#+g' docs/*.md
10+
sed -i 's+(../README.md)+(HOW-TO.md)+g' docs/*.md

0 commit comments

Comments
 (0)