-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from arash-r1c/main
Create auto-generated release
- Loading branch information
Showing
37 changed files
with
489 additions
and
2,608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @hatamiarash7 | ||
* @arash-r1c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
# CGO | ||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
# Other | ||
_testmain.go | ||
*.exe | ||
*.test | ||
*.prof | ||
.DS_Store | ||
|
||
# IDE | ||
.vscode | ||
|
||
# Generator | ||
.openapi-generator-ignore | ||
.openapi-generator | ||
.travis.yml | ||
git_push.sh |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# ArvanCloud CDN Go | ||
|
||
[![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) | ||
|
||
![logo](.github/logo.svg) | ||
|
||
It's a Go library for interacting with the ArvanCloud CDN API. | ||
|
||
## Installation | ||
|
||
```bash | ||
go get github.com/arvancloud/cdn-go | ||
``` | ||
|
||
## Usage | ||
|
||
Check the [HOW-TO.md](docs/HOW-TO.md) file for more information. | ||
|
||
## Contributing | ||
|
||
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
packageName: r1cdn | ||
generateInterfaces: false | ||
packageVersion: 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
# Go API client for {{packageName}} | ||
|
||
Use this documentation to learn how to use the ArvanCloud SDK. | ||
|
||
**API version**: {{appVersion}} | ||
|
||
## Dependencies | ||
|
||
Install the following packages: | ||
|
||
```shell | ||
go get github.com/stretchr/testify/assert | ||
{{#hasOAuthMethods}} | ||
go get golang.org/x/oauth2 | ||
{{/hasOAuthMethods}} | ||
go get golang.org/x/net/context | ||
``` | ||
|
||
## Usage | ||
|
||
Get the package: | ||
|
||
```bash | ||
go get github.com/arvancloud/cdn-go | ||
``` | ||
|
||
Put the package under your project folder and add the following in import: | ||
|
||
```golang | ||
import {{packageName}} "github.com/arvancloud/cdn-go" | ||
``` | ||
|
||
## Configuration of Server URL | ||
|
||
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. | ||
|
||
### Select Server Configuration | ||
|
||
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`. | ||
|
||
```golang | ||
ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerIndex, 1) | ||
``` | ||
|
||
### Templated Server URL | ||
|
||
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`. | ||
|
||
```golang | ||
ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerVariables, map[string]string{ | ||
"basePath": "v2", | ||
}) | ||
``` | ||
|
||
Note, enum values are always validated and all unused variables are silently ignored. | ||
|
||
### URLs Configuration per Operation | ||
|
||
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. | ||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string. | ||
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps. | ||
|
||
```golang | ||
ctx := context.WithValue(context.Background(), {{packageName}}.ContextOperationServerIndices, map[string]int{ | ||
"{classname}Service.{nickname}": 2, | ||
}) | ||
ctx = context.WithValue(context.Background(), {{packageName}}.ContextOperationServerVariables, map[string]map[string]string{ | ||
"{classname}Service.{nickname}": { | ||
"port": "8443", | ||
}, | ||
}) | ||
``` | ||
|
||
## Documentation for API Endpoints | ||
|
||
All URIs are relative to *{{basePath}}* | ||
|
||
Class | Method | HTTP request | Description | ||
------------ | ------------- | ------------- | ------------- | ||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}} | ||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} | ||
|
||
## Documentation For Models | ||
|
||
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) | ||
{{/model}}{{/models}} | ||
|
||
## Documentation For Authorization | ||
|
||
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}} | ||
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}} | ||
{{#authMethods}} | ||
### {{{name}}} | ||
|
||
{{#isApiKey}} | ||
- **Type**: API key | ||
- **API key parameter name**: {{{keyParamName}}} | ||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} | ||
|
||
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. | ||
|
||
Example | ||
|
||
```golang | ||
auth := context.WithValue( | ||
context.Background(), | ||
sw.ContextAPIKeys, | ||
map[string]sw.APIKey{ | ||
"{{keyParamName}}": {Key: "API_KEY_STRING"}, | ||
}, | ||
) | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
|
||
{{/isApiKey}} | ||
{{#isBasic}} | ||
{{#isBasicBearer}} | ||
- **Type**: HTTP Bearer token authentication | ||
|
||
Example | ||
|
||
```golang | ||
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING") | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
|
||
{{/isBasicBearer}} | ||
{{#isBasicBasic}} | ||
- **Type**: HTTP basic authentication | ||
|
||
Example | ||
|
||
```golang | ||
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{ | ||
UserName: "username", | ||
Password: "password", | ||
}) | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
|
||
{{/isBasicBasic}} | ||
{{#isHttpSignature}} | ||
- **Type**: HTTP signature authentication | ||
|
||
Example | ||
|
||
```golang | ||
authConfig := client.HttpSignatureAuth{ | ||
KeyId: "my-key-id", | ||
PrivateKeyPath: "rsa.pem", | ||
Passphrase: "my-passphrase", | ||
SigningScheme: sw.HttpSigningSchemeHs2019, | ||
SignedHeaders: []string{ | ||
sw.HttpSignatureParameterRequestTarget, // The special (request-target) parameter expresses the HTTP request target. | ||
sw.HttpSignatureParameterCreated, // Time when request was signed, formatted as a Unix timestamp integer value. | ||
"Host", // The Host request header specifies the domain name of the server, and optionally the TCP port number. | ||
"Date", // The date and time at which the message was originated. | ||
"Content-Type", // The Media type of the body of the request. | ||
"Digest", // A cryptographic digest of the request body. | ||
}, | ||
SigningAlgorithm: sw.HttpSigningAlgorithmRsaPSS, | ||
SignatureMaxValidity: 5 * time.Minute, | ||
} | ||
var authCtx context.Context | ||
var err error | ||
if authCtx, err = authConfig.ContextWithValue(context.Background()); err != nil { | ||
// Process error | ||
} | ||
r, err = client.Service.Operation(auth, args) | ||
|
||
``` | ||
{{/isHttpSignature}} | ||
{{/isBasic}} | ||
{{#isOAuth}} | ||
|
||
- **Type**: OAuth | ||
- **Flow**: {{{flow}}} | ||
- **Authorization URL**: {{{authorizationUrl}}} | ||
- **Scopes**: {{^scopes}}N/A{{/scopes}} | ||
{{#scopes}} - **{{{scope}}}**: {{{description}}} | ||
{{/scopes}} | ||
|
||
Example | ||
|
||
```golang | ||
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING") | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
|
||
Or via OAuth2 module to automatically refresh tokens and perform user authentication. | ||
|
||
```golang | ||
import "golang.org/x/oauth2" | ||
|
||
/* Perform OAuth2 round trip request and obtain a token */ | ||
|
||
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) | ||
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource) | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
|
||
{{/isOAuth}} | ||
{{/authMethods}} | ||
|
||
## Documentation for Utility Methods | ||
|
||
Due to the fact that model structure members are all pointers, this package contains | ||
a number of utility functions to easily obtain pointers to values of basic types. | ||
Each of these functions takes a value of the given basic type and returns a pointer to it: | ||
|
||
* `PtrBool` | ||
* `PtrInt` | ||
* `PtrInt32` | ||
* `PtrInt64` | ||
* `PtrFloat` | ||
* `PtrFloat32` | ||
* `PtrFloat64` | ||
* `PtrString` | ||
* `PtrTime` | ||
|
||
## Author | ||
|
||
{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} | ||
{{/-last}}{{/apis}}{{/apiInfo}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
cat .github/generator/.gitignore >>.gitignore | ||
mv README.md docs/HOW-TO.md | ||
cp .github/generator/*.md . | ||
sed -i 's/GIT_USER_ID/arvancloud/g' go.mod test/*.go docs/*.md | ||
sed -i 's/GIT_REPO_ID/cdn-go/g' go.mod test/*.go docs/*.md | ||
sed -i 's+(docs/+(+g' docs/*.md | ||
sed -i 's+../README.md#+HOW-TO.md#+g' docs/*.md | ||
sed -i 's+(../README.md)+(HOW-TO.md)+g' docs/*.md |
Oops, something went wrong.