Skip to content

Commit 490ba26

Browse files
authored
Merge pull request #2 from Keyfactor/untrusted_root
Regenerate documentation and add support for untrusted root
2 parents 195d8a9 + 5579733 commit 490ba26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1191
-962
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ _testmain.go
2525

2626
.idea
2727
.openapi-generator
28-
Keyfactor-v10-patched.swagger.yaml
29-
Makefile
28+
.DS_Store
29+
*.yaml

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
GO_PACKAGE_NAME = keyfactor
2+
GIT_USER_ID = Keyfactor
3+
GIT_REPO_NAME = keyfactor-go-client-sdk
4+
OPENAPI_YAML = Keyfactor-v10-patched.swagger.yaml
5+
OPENAPI_GENERATOR_VERSION = 6.3.0
6+
OPENAPI_TEMPLATE_DIR = .openapi-generator/templates/go
7+
8+
init:
9+
@echo "Initializing..."
10+
@wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(OPENAPI_GENERATOR_VERSION)/openapi-generator-cli-$(OPENAPI_GENERATOR_VERSION).jar -O openapi-generator-cli.jar
11+
12+
deinit:
13+
@echo "Cleaning up..."
14+
@rm openapi-generator-cli.jar
15+
@rm api/openapi.yaml
16+
17+
generate: clean init
18+
@echo "Generating..."
19+
@if [ -d $(OPENAPI_TEMPLATE_DIR) ]; \
20+
then \
21+
java -jar openapi-generator-cli.jar generate -i $(OPENAPI_YAML) -p packageName=$(GO_PACKAGE_NAME) $(OPENAPI_ARGS) -g go -p isGoSubmodule=false -p disallowAdditionalPropertiesIfNotPresent=false --git-user-id $(GIT_USER_ID) --git-repo-id $(GIT_REPO_NAME) -t $(OPENAPI_TEMPLATE_DIR); \
22+
else \
23+
java -jar openapi-generator-cli.jar generate -i $(OPENAPI_YAML) -p packageName=$(GO_PACKAGE_NAME) $(OPENAPI_ARGS) -g go -p isGoSubmodule=false -p disallowAdditionalPropertiesIfNotPresent=false --git-user-id $(GIT_USER_ID) --git-repo-id $(GIT_REPO_NAME); \
24+
fi
25+
@mkdir ./api/$(GO_PACKAGE_NAME) || (echo /api/$(GO_PACKAGE_NAME) exists)
26+
@mv -f ./*.go ./api/$(GO_PACKAGE_NAME) || (echo no files to move)
27+
@rm .travis.yml || (echo no .travis.yml to remove)
28+
@rm .openapi-generator-ignore || (echo no .openapi-generator-ignore to remove)
29+
@rm git_push.sh || (echo no git_push.sh to remove)
30+
@make deinit
31+
@echo "Done."
32+
33+
clean:
34+
@echo "Cleaning..."
35+
@rm -rf ./api/$(GO_PACKAGE_NAME) || (echo no ./api/$(GO_PACKAGE_NAME) to remove)
36+
@rm -rf ./go.mod || (echo no ./go.mod to remove)
37+
@rm -rf ./go.sum || (echo no ./go.sum to remove)
38+
@rm -rf ./docs || (echo no ./docs to remove)
39+
@rm -rf ./test || (echo no ./test to remove)
40+
41+
template: init
42+
@mkdir -p $(OPENAPI_TEMPLATE_DIR)
43+
@echo "Generating Templates..."
44+
@java -jar openapi-generator-cli.jar author template -g go -o $(OPENAPI_TEMPLATE_DIR)
45+
@echo "Cleaning up..."
46+
@rm openapi-generator-cli.jar
47+
@echo "Done."

README.md

Lines changed: 51 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
This reference serves to document REST-based methods to manage and integrate with Keyfactor. In addition, an embedded interface allows for the execution of calls against the current Keyfactor API instance.
44

5-
# Support for the Keyfactor Go Client SDK
6-
7-
We welcome contributions.
8-
9-
The Keyfactor Command Go Client SDK is open source and community supported, meaning that there is no SLA applicable for these tools.
10-
11-
To report a problem or suggest a new feature, use the [Issues](https://github.com/Keyfactor/keyfactor-go-client-sdk/issues) tab. If you want to contribute actual bug fixes or proposed enhancements, use the [Pull requests](https://github.com/Keyfactor/keyfactor-go-client-sdk/pulls) tab.
12-
135
## Overview
146
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.
157

@@ -22,61 +14,73 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
2214
Install the following dependencies:
2315

2416
```shell
25-
go get github.com/stretchr/testify/assert
26-
go get golang.org/x/net/context
17+
go get "github.com/Keyfactor/keyfactor-go-client-sdk"
2718
```
2819

2920
Put the package under your project folder and add the following in import:
3021

3122
```golang
32-
import keyfactor "github.com/Keyfactor/keyfactor-go-client-sdk"
23+
import "github.com/Keyfactor/keyfactor-go-client-sdk/api/keyfactor"
3324
```
3425

35-
To use a proxy, set the environment variable `HTTP_PROXY`:
36-
37-
```golang
38-
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
26+
## Configuration
27+
28+
The `keyfactor.NewConfiguration()` method is used to configure the Keyfactor Go Client SDK. The client can be configured
29+
by passing a map of configuration options to the `NewConfiguration()` method, or by passing a blank map and setting
30+
the configuration options individually on the returned `Configuration` object.
31+
32+
The following configuration options are available:
33+
```go
34+
// Create a configuration map
35+
config := make(map[string]string)
36+
config["host"] = "keyfactor.example.com"
37+
config["username"] = "admin"
38+
config["password"] = "password"
39+
config["domain"] = "example.com" // optional
40+
config["caCertificatePath"] = "/path/to/local/certificate" // optional
41+
42+
// Create a configuration object
43+
ejbcaConfiguration := keyfactor.NewConfiguration(config)
44+
if ejbcaConfiguration == nil {
45+
// handle error
46+
}
47+
48+
// Create a client
49+
client := keyfactor.NewAPIClient(config)
50+
if client == nil {
51+
// handle error
52+
}
3953
```
4054

41-
## Configuration of Server URL
42-
43-
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
55+
or
4456

45-
### Select Server Configuration
57+
```go
58+
// Create a configuration object
59+
ejbcaConfiguration := keyfactor.NewConfiguration(make(map[string]string))
4660

47-
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
61+
// Set configuration options individually
62+
ejbcaConfiguration.Host = "keyfactor.example.com"
63+
ejbcaConfiguration.BasicAuth.UserName = "admin"
64+
ejbcaConfiguration.BasicAuth.Password = "password"
65+
ejbcaConfiguration.CaCertificatePath = "/path/to/local/certificate" // optional
4866

49-
```golang
50-
ctx := context.WithValue(context.Background(), keyfactor.ContextServerIndex, 1)
67+
// Create a client
68+
client := keyfactor.NewAPIClient(ejbcaConfiguration)
69+
if client == nil {
70+
// handle error
71+
}
5172
```
5273

53-
### Templated Server URL
74+
The root CA certificate can also be configured by passing a slice of `*x509.Certificate` objects to the `ejbca.Configuration.SetCaCertificates()` method.
75+
```go
76+
// Create a configuration object
77+
ejbcaConfiguration := keyfactor.NewConfiguration(make(map[string]string))
5478

55-
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
79+
// Set the root CA certificate
80+
ejbcaConfiguration.SetCaCertificates([]*x509.Certificate{caCertificate})
5681

57-
```golang
58-
ctx := context.WithValue(context.Background(), keyfactor.ContextServerVariables, map[string]string{
59-
"basePath": "v2",
60-
})
61-
```
62-
63-
Note, enum values are always validated and all unused variables are silently ignored.
64-
65-
### URLs Configuration per Operation
66-
67-
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
68-
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
69-
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
70-
71-
```golang
72-
ctx := context.WithValue(context.Background(), keyfactor.ContextOperationServerIndices, map[string]int{
73-
"{classname}Service.{nickname}": 2,
74-
})
75-
ctx = context.WithValue(context.Background(), keyfactor.ContextOperationServerVariables, map[string]map[string]string{
76-
"{classname}Service.{nickname}": {
77-
"port": "8443",
78-
},
79-
})
82+
// Create a client
83+
client := keyfactor.NewAPIClient(ejbcaConfiguration)
8084
```
8185

8286
## Documentation for API Endpoints
@@ -767,25 +771,6 @@ Class | Method | HTTP request | Description
767771
- [ModelsWorkflowProcessedCertificateRequest](docs/ModelsWorkflowProcessedCertificateRequest.md)
768772

769773

770-
## Documentation For Authorization
771-
772-
773-
774-
### basicAuth
775-
776-
- **Type**: HTTP basic authentication
777-
778-
Example
779-
780-
```golang
781-
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
782-
UserName: "username",
783-
Password: "password",
784-
})
785-
r, err := client.Service.Operation(auth, args)
786-
```
787-
788-
789774
## Documentation for Utility Methods
790775

791776
Due to the fact that model structure members are all pointers, this package contains

api/keyfactor/api_agent_pool.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/keyfactor/api_certificate.go

Lines changed: 30 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/keyfactor/api_certificate_collection.go

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)