Skip to content

Commit

Permalink
Regenerate documentation and add support for untrusted root
Browse files Browse the repository at this point in the history
  • Loading branch information
Hayden Roszell committed Aug 16, 2023
1 parent 195d8a9 commit 5579733
Show file tree
Hide file tree
Showing 55 changed files with 1,191 additions and 962 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ _testmain.go

.idea
.openapi-generator
Keyfactor-v10-patched.swagger.yaml
Makefile
.DS_Store
*.yaml
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
GO_PACKAGE_NAME = keyfactor
GIT_USER_ID = Keyfactor
GIT_REPO_NAME = keyfactor-go-client-sdk
OPENAPI_YAML = Keyfactor-v10-patched.swagger.yaml
OPENAPI_GENERATOR_VERSION = 6.3.0
OPENAPI_TEMPLATE_DIR = .openapi-generator/templates/go

init:
@echo "Initializing..."
@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

deinit:
@echo "Cleaning up..."
@rm openapi-generator-cli.jar
@rm api/openapi.yaml

generate: clean init
@echo "Generating..."
@if [ -d $(OPENAPI_TEMPLATE_DIR) ]; \
then \
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); \
else \
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); \
fi
@mkdir ./api/$(GO_PACKAGE_NAME) || (echo /api/$(GO_PACKAGE_NAME) exists)
@mv -f ./*.go ./api/$(GO_PACKAGE_NAME) || (echo no files to move)
@rm .travis.yml || (echo no .travis.yml to remove)
@rm .openapi-generator-ignore || (echo no .openapi-generator-ignore to remove)
@rm git_push.sh || (echo no git_push.sh to remove)
@make deinit
@echo "Done."

clean:
@echo "Cleaning..."
@rm -rf ./api/$(GO_PACKAGE_NAME) || (echo no ./api/$(GO_PACKAGE_NAME) to remove)
@rm -rf ./go.mod || (echo no ./go.mod to remove)
@rm -rf ./go.sum || (echo no ./go.sum to remove)
@rm -rf ./docs || (echo no ./docs to remove)
@rm -rf ./test || (echo no ./test to remove)

template: init
@mkdir -p $(OPENAPI_TEMPLATE_DIR)
@echo "Generating Templates..."
@java -jar openapi-generator-cli.jar author template -g go -o $(OPENAPI_TEMPLATE_DIR)
@echo "Cleaning up..."
@rm openapi-generator-cli.jar
@echo "Done."
117 changes: 51 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

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.

# Support for the Keyfactor Go Client SDK

We welcome contributions.

The Keyfactor Command Go Client SDK is open source and community supported, meaning that there is no SLA applicable for these tools.

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.

## Overview
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.

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

```shell
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
go get "github.com/Keyfactor/keyfactor-go-client-sdk"
```

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

```golang
import keyfactor "github.com/Keyfactor/keyfactor-go-client-sdk"
import "github.com/Keyfactor/keyfactor-go-client-sdk/api/keyfactor"
```

To use a proxy, set the environment variable `HTTP_PROXY`:

```golang
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
## Configuration

The `keyfactor.NewConfiguration()` method is used to configure the Keyfactor Go Client SDK. The client can be configured
by passing a map of configuration options to the `NewConfiguration()` method, or by passing a blank map and setting
the configuration options individually on the returned `Configuration` object.

The following configuration options are available:
```go
// Create a configuration map
config := make(map[string]string)
config["host"] = "keyfactor.example.com"
config["username"] = "admin"
config["password"] = "password"
config["domain"] = "example.com" // optional
config["caCertificatePath"] = "/path/to/local/certificate" // optional

// Create a configuration object
ejbcaConfiguration := keyfactor.NewConfiguration(config)
if ejbcaConfiguration == nil {
// handle error
}

// Create a client
client := keyfactor.NewAPIClient(config)
if client == nil {
// handle error
}
```

## Configuration of Server URL

Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
or

### Select Server Configuration
```go
// Create a configuration object
ejbcaConfiguration := keyfactor.NewConfiguration(make(map[string]string))

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

```golang
ctx := context.WithValue(context.Background(), keyfactor.ContextServerIndex, 1)
// Create a client
client := keyfactor.NewAPIClient(ejbcaConfiguration)
if client == nil {
// handle error
}
```

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

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

```golang
ctx := context.WithValue(context.Background(), keyfactor.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(), keyfactor.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), keyfactor.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
// Create a client
client := keyfactor.NewAPIClient(ejbcaConfiguration)
```

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


## Documentation For Authorization



### basicAuth

- **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)
```


## Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains
Expand Down
4 changes: 2 additions & 2 deletions api/keyfactor/api_agent_pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 30 additions & 30 deletions api/keyfactor/api_certificate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions api/keyfactor/api_certificate_collection.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5579733

Please sign in to comment.