Skip to content

Latest commit

 

History

History
197 lines (158 loc) · 11.4 KB

File metadata and controls

197 lines (158 loc) · 11.4 KB

Go API client for Keyfactor Command (API Version V2)

This page provides a utility through which the Keyfactor API endpoints can be called and results returned. It is intended to be used primarily for validation, testing and workflow development. It also serves secondarily as documentation for the API.

If you would like to view documentation containing details on the Keyfactor API and endpoints, please refer to the Web API section of the Keyfactor Command documentation.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • Keyfactor Command API Version: 25.1.1
  • API version: 2
  • Package version: 1.0.0
  • OpenAPI Generator Version: 7.12.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

For more information on the Keyfactor Command API Documentation, please visit here.

For more information on OpenAPI Generator, please visit its documentation.

Installation

Install the following dependencies:

go get "github.com/Keyfactor/keyfactor-go-client-sdk/v25"

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

import "github.com/Keyfactor/keyfactor-go-client-sdk/v25/api/keyfactor/v2"

Configuration

Configuration of the API client is done through the github.com/Keyfactor/keyfactor-auth-client-go/auth_providers Go package.

Here is an example of configuring your API client:

import (
	"context"
	"io"
	"os"

	"github.com/Keyfactor/keyfactor-auth-client-go/auth_providers"
	v2 "github.com/Keyfactor/keyfactor-go-client-sdk/v25/api/keyfactor/v2"
)

hostname := os.Getenv(auth_providers.EnvKeyfactorHostName)
apiPath := os.Getenv(auth_providers.EnvKeyfactorAPIPath)

clientId := os.Getenv(auth_providers.EnvKeyfactorClientID)
clientSecret := os.Getenv(auth_providers.EnvKeyfactorClientSecret)
tokenUrl := os.Getenv(auth_providers.EnvKeyfactorAuthTokenURL)

context := context.Background()

oAuthNoParamsConfig := auth_providers.CommandConfigOauth{}
oAuthNoParamsConfig.CommandAuthConfig.
	WithCommandHostName(hostname).
	WithCommandAPIPath(apiPath).
	WithSkipVerify(false).
	WithClientTimeout(10)
oAuthNoParamsConfig.
	WithClientId(clientId).
	WithClientSecret(clientSecret).
	WithTokenUrl(tokenUrl).
	Authenticate()

// Configure API client
client, err := keyfactor.NewAPIClient(oAuthNoParamsConfig.GetServerConfig())

// Mock example API request. Please refer to documentation for a complete list of valid API requests.
api := client.ExampleApi
req := api.NewCreateExampleRequest(ctx)

// If applicable, you can add the body to an API request through the request builder's Fluent API.
req = req.ExampleCreateRequest(v2.ExampleExampleCreateRequest{
	Name: "Foo",
	Description: "Example API request."
})

// Execute the API request by calling the `.Execute()` method on the request object.
response, httpResp, err := req.Execute()
if err != nil {
	// Handle the error accordingly to fit your needs.
	if httpResp != nil {
		defer httpResp.Body.Close()
		body, err := io.ReadAll(httpResp.Body)
	}
}

// Do something with the response
id := response.Id

// You may also access the properties of the API response data through getter methods.
// id := response.GetId()

Documentation for API Endpoints

All URIs are relative to http://keyfactor.example.com

Class Method HTTP request Description
CertificateApi GetCertificatesIdentityAuditById Get /Certificates/IdentityAudit/{id} Audit identity permissions for certificate
EnrollmentApi CreateEnrollmentPFX Post /Enrollment/PFX Performs a PFX Enrollment based upon the provided request
PAMProviderApi CreatePamProviders Post /PamProviders Creates a new PAM provider with the associated properties
PAMProviderApi CreatePamProvidersTypes Post /PamProviders/Types Creates a new PAM provider type with the associated properties
PAMProviderApi DeletePamProvidersById Delete /PamProviders/{id} Deletes a PAM Provider
PAMProviderApi GetPamProviders Get /PamProviders Returns all PAM providers according to the provided filter and output parameters
PAMProviderApi GetPamProvidersById Get /PamProviders/{id} Returns a single PAM Provider that matches the associated id
PAMProviderApi GetPamProvidersTypes Get /PamProviders/Types Returns all PAM provider types in the Keyfactor instance
PAMProviderApi GetPamProvidersTypesById Get /PamProviders/Types/{id} Returns PAM provider Type for a specific PAM provider
PAMProviderApi UpdatePamProviders Put /PamProviders Updates an existing PAM provider according to the provided properties
SMTPApi GetSMTP Get /SMTP Gets SMTP profile data
SMTPApi UpdateSMTP Put /SMTP Updates SMTP profile data
SecurityRolesApi CreateSecurityRoles Post /Security/Roles Adds a new security role to the system.
SecurityRolesApi GetSecurityRoles Get /Security/Roles Returns all security roles according to the provided filter and output parameters.
SecurityRolesApi GetSecurityRolesById Get /Security/Roles/{id} Returns a single security role that matches the id.
SecurityRolesApi UpdateSecurityRoles Put /Security/Roles Updates an existing security role.
UserApi GetSSHUsers Get /SSH/Users Returns users matching the criteria from the provided query parameters
UserApi GetSSHUsersById Get /SSH/Users/{id} Looks up information about an existing SSH user.

Documentation For Models

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