go get -u github.com/infra-rdc/rudder-go
package main
import (
"context"
rudder "github.com/infra-rdc/rudder-go"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
ctx := context.Background()
res, err := s.ChangeRequests.ListChangeRequests(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
- ListChangeRequests - List all change requests
- ChangeRequestDetails - Get a change request details
- DeclineChangeRequest - Decline a request details
- UpdateChangeRequest - Update a request details
- AcceptChangeRequest - Accept a request details
- ListUsers - List user
- SaveWorkflowUser - Update validated user list
- RemoveValidatedUser - Remove an user from validated user list
- Export - Get a ZIP archive of the requested items and their dependencies
- Import - Import a ZIP archive of policies into Rudder
- GetAllCampaignEvents - Get all campaign events
- GetCampaignEvent - Get a campaign event details
- SaveCampaignEvent - Update an existing event
- DeleteCampaignEvent - Delete a campaign event details
- GetEventsCampaign - Get campaign events for a campaign
- ScheduleCampaign - Schedule a campaign event for a campaign
- GetGlobalCompliance - Global compliance
- GetDirectivesCompliance - Compliance details for all directives
- GetDirectiveComplianceID - Compliance details by directive
- GetNodesCompliance - Compliance details for all nodes
- GetNodeCompliance - Compliance details by node
- GetRulesCompliance - Compliance details for all rules
- GetRuleCompliance - Compliance details by rule
- GetAllCve - Get all CVE details
- CheckCVE - Trigger a CVE check
- GetCVECheckConfiguration - Get CVE check config
- UpdateCVECheckConfiguration - Update cve check config
- GetLastCVECheck - Get last CVE check result
- GetCVEList - Get a list of CVE details
- UpdateCVE - Update CVE database from remote source
- ReadCVEfromFS - Update CVE database from file system
- GetCve - Get a CVE details
- GetAllDataSources - List all data sources
- ReloadAllDatasourcesAllNodes - Update properties from data sources
- ReloadOneDatasourceAllNodes - Update properties from data sources
- GetDataSource - Get data source configuration
- DeleteDataSource - Delete a data source
- ReloadAllDatasourcesOneNode - Update properties for one node from all data sources
- ReloadOneDatasourceOneNode - Update properties for one node from a data source
- ListDirectives - List all directives
- CreateDirective - Create a directive
- DirectiveDetails - Get directive details
- DeleteDirective - Delete a directive
- ListGroups - List all groups
- CreateGroup - Create a group
- GetGroupCategoryDetails - Get group category details
- DeleteGroupCategory - Delete group category
- UpdateGroupCategory - Update group category details
- GetGroupTree - Get groups tree
- GroupDetails - Get group details
- UpdateGroup - Update group details
- DeleteGroup - Delete a group
- ReloadGroup - Reload a group
- APIGeneralInformations - List all endpoints
- APIInformations - Get information about one API endpoint
- APISubInformations - Get information on endpoint in a section
- QueueInformation - Get information about inventory processing queue
- UploadInventory - Upload an inventory for processing
- FileWatcherRestart - Restart inventory watcher
- FileWatcherStart - Start inventory watcher
- FileWatcherStop - Stop inventory watcher
- Methods - List methods
- ReloadMethods - Reload methods
- ListTechniques - List all techniques
- Techniques - Reload techniques
- ListTechniquesVersions - List versions
- GetTechniqueAllVersion - Technique metadata by ID
- ListTechniquesDirectives - List all directives based on a technique
- DeleteTechnique - Delete technique
- GetTechniqueAllVersionID - Technique metadata by version and ID
- ListTechniqueVersionDirectives - List all directives based on a version of a technique
- GetTechniquesResources - Technique's resources
- TechniqueRevisions - Technique's revisions
- ListAcceptedNodes - List managed nodes
- CreateNodes - Create one or several new nodes
- ApplyPolicyAllNodes - Trigger an agent run on all nodes
- ListPendingNodes - List pending nodes
- ChangePendingNodeStatus - Update pending Node status
- GetNodesStatus - Get nodes acceptation status
- NodeDetails - Get information about a node
- UpdateNode - Update node settings and properties
- DeleteNode - Delete a node
- ApplyPolicy - Trigger an agent run
- NodeInheritedProperties - Get inherited node properties for a node
- OpenscapReport - Get an OpenSCAP report
- ListParameters - List all global properties
- ParameterDetails - Get the value of a global property
- UpdateParameter - Update a global property's value
- DeleteParameter - Delete a global parameter
- PluginSettings - Get plugins repository settings
- UpdateSettings - Update plugins settings
- GetRuleCategoryDetails - Get rule category details
- DeleteRuleCategory - Delete group category
- UpdateRuleCategory - Update rule category details
- GetRuleTree - Get rules tree
- DemoteToNode - Demote a relay to simple node
- PromoteToRelay - Promote a node to relay
- GetAllSecrets - List all secrets
- UpdateSecret - Update a secret
- AddSecret - Create a secret
- GetSecret - Get one secret
- DeleteSecret - Delete a secret
- GetAllSettings - List all settings
- GetAllowedNetworks - Get allowed networks for a policy server
- SetAllowedNetworks - Set allowed networks for a policy server
- ModifyAllowedNetworks - Modify allowed networks for a policy server
- GetSetting - Get the value of a setting
- ModifySetting - Set the value of a setting
- None - Check if Rudder is alive
- ListArchives - List archives
- CreateArchive - Create an archive
- RestoreArchive - Restore an archive
- GetZipArchive - Get an archive as a ZIP
- GetHealthcheckResult - Get healthcheck
- GetSystemInfo - Get server information
- PurgeSoftware - Trigger batch for cleaning unreferenced software
- RegeneratePolicies - Trigger a new policy generation
- ReloadAll - Reload both techniques and dynamic groups
- ReloadGroups - Reload dynamic groups
- ReloadTechniques - Reload techniques
- GetStatus - Get server status
- UpdatePolicies - Trigger update of policies
- GetCampaignResults - Get a campaign result history
- GetCampaignEventResult - Get a campaign event result
- GetSystemUpdateResultForNode - Get detailed campaign event result for a Node
- AddUser - Add user
- GetRole - List all roles
- UpdateUser - Update user's infos
- GetUserInfo - List all users
- ReloadUserConf - Reload user
- DeleteUser - Delete an user
Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass.
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.DeleteParameterResponseBody | 500 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
package main
import (
"context"
"errors"
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/sdkerrors"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var parameterID string = "rudder_file_edit_header"
ctx := context.Background()
res, err := s.Parameters.DeleteParameter(ctx, parameterID)
if err != nil {
var e *sdkerrors.DeleteParameterResponseBody
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *sdkerrors.SDKError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
}
}
You can override the default server globally using the WithServerIndex
option when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
# | Server | Variables |
---|---|---|
0 | https://rudder.example.local/rudder/api/latest |
None |
package main
import (
"context"
rudder "github.com/infra-rdc/rudder-go"
"log"
)
func main() {
s := rudder.New(
rudder.WithServerIndex(0),
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
ctx := context.Background()
res, err := s.ChangeRequests.ListChangeRequests(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
The default server can also be overridden globally using the WithServerURL
option when initializing the SDK client instance. For example:
package main
import (
"context"
rudder "github.com/infra-rdc/rudder-go"
"log"
)
func main() {
s := rudder.New(
rudder.WithServerURL("https://rudder.example.local/rudder/api/latest"),
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
ctx := context.Background()
res, err := s.ChangeRequests.ListChangeRequests(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}
The built-in net/http
client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.
import (
"net/http"
"time"
"github.com/myorg/your-go-sdk"
)
var (
httpClient = &http.Client{Timeout: 30 * time.Second}
sdkClient = sdk.New(sdk.WithClient(httpClient))
)
This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
APITokens |
apiKey | API key |
You can configure it using the WithSecurity
option when initializing the SDK client instance. For example:
package main
import (
"context"
rudder "github.com/infra-rdc/rudder-go"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
ctx := context.Background()
res, err := s.ChangeRequests.ListChangeRequests(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
This SDK defines the following custom types to assist with marshalling and unmarshalling data.
types.Date
is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02".
d1 := types.NewDate(time.Now()) // returns *types.Date
d2 := types.DateFromTime(time.Now()) // returns types.Date
d3, err := types.NewDateFromString("2019-01-01") // returns *types.Date, error
d4, err := types.DateFromString("2019-01-01") // returns types.Date, error
d5 := types.MustNewDateFromString("2019-01-01") // returns *types.Date and panics on error
d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on error
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!
Julien Briault - @ju_hnny5