Categorygithub.com/opslevel/opslevel-go/v2022
modulepackage
2022.12.16
Repository: https://github.com/opslevel/opslevel-go.git
Documentation: pkg.go.dev

# README

Overall

opslevel-go

Package opslevel provides an OpsLevel API client implementation.

NOTE: this library is still a WIP and does not match the API 100% yet

Installation

opslevel requires Go version 1.8 or later.

go get -u github.com/opslevel/opslevel-go

Usage

Construct a client, specifying the API token. Then, you can use it to make GraphQL queries and mutations.

client := opslevel.NewClient("XXX_API_TOKEN_XXX")
// Use client...

You can validate the client can successfully talk to the OpsLevel API.

client := opslevel.NewClient("XXX_API_TOKEN_XXX")
if err := client.Validate(); err != nil {
	panic(err)
}

Every resource (IE: service, lifecycle, tier, etc) in OpsLevel API has a corresponding data structure in go as well as the graphql query & mutation inputs. Additionally there is also some helper functions that use native go types like string and []string to make it easier to work with. The following are a handful of examples:

Find a service given an alias and print the owning team name:

foundService, foundServiceErr := client.GetServiceWithAlias("MyCoolService")
if foundServiceErr != nil {

	panic(foundServiceErr)
}
fmt.Println(foundService.Owner.Name)

Create a new service in OpsLevel and print the ID:

serviceCreateInput := opslevel.ServiceCreateInput{
	Name:        "MyCoolService",
	Product:     "MyProduct",
	Description: "The Coolest Service",
	Language:    "go",
}
newService, newServiceErr := client.CreateService(serviceCreateInput)
if newServiceErr != nil {
	panic(newServiceErr)
}
fmt.Println(newService.Id)

Assign the tag {"hello": "world"} to our newly created service and print all the tags currently on it:

allTagsOnThisService, err := client.AssignTagForId(newService.Id, "Hello", "World")
for tagKey, tagValue := range allTagsOnThisService {
	fmt.Printf("Tag '{%s : %s}'", tagKey, tagValue)
}

List all the tags for a service:

tags, tagsErr := client.GetTagsForServiceWithAlias("MyCoolService")
for _, tag := range tags {
	fmt.Printf("Tag '{%s : %s}'\n", tag.Key, tag.Value)
}
// OR
service, serviceErr := client.GetServiceWithAlias("MyCoolService")
tags, tagsErr := client.GetTagsForService(service.Id)
for _, tag := range tags {
	fmt.Printf("Tag '{%s : %s}'\n", tag.Key, tag.Value)
}

Build a lookup table of teams:

func GetTeams(client *opslevel.Client) (map[string]opslevel.Team, error) {
	teams := make(map[string]opslevel.Team)
	data, dataErr := client.ListTeams()
	if dataErr != nil {
		return teams, dataErr
	}
	for _, team := range data {
		teams[string(team.Alias)] = team
	}
	return teams, nil
}

Advanced Usage

The client also exposes functions Query and Mutate for doing custom query or mutations. We are running ontop of this go graphql library so you can read up on how to define go structures that represent a query or mutation there but examples of each can be found here.

# Packages

Wrapping the client can be useful when you want to override default behavior, such as always setting context or disallowing (to the best of Go's ability) access to specific receiver functions on `opslevel.Client`.

# Functions

All AlertSourceTypeEnum as []string.
All AliasOwnerTypeEnum as []string.
All ApiDocumentSourceEnum as []string.
All CheckStatus as []string.
All CheckType as []string.
All ConnectiveEnum as []string.
All ContactType as []string.
All FrequencyTimeScale as []string.
All HasDocumentationSubtypeEnum as []string.
All HasDocumentationTypeEnum as []string.
All PredicateKeyEnum as []string.
All PredicateTypeEnum as []string.
All RunnerJobOutcomeEnum as []string.
All RunnerJobStatusEnum as []string.
All RunnerStatusTypeEnum as []string.
All ContactType as []string.
All ServicePropertyTypeEnum as []string.
All TaggableResource as []string.
All ToolCategory as []string.
All UserRole as []string.
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Deprecated: Use NewGQLClient instead.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

A Datadog alert source (aka monitor).
An Opsgenie alert source (aka service).
A PagerDuty alert source (aka service).
Aliases that are assigned to services.
Aliases that are assigned to teams.
Use the document that was pulled by OpsLevel via a repo.
Use the document that was pushed to OpsLevel via an API Docs integration.
The check evaluated to a falsy value based on some conditions.
The check evaluated to a truthy value based on some conditions.
The check has not been evaluated yet..
Verifies that the service has an alert source of a particular type or name.
Allows for the creation of programmatic checks that use an API to mark the status as passing or failing.
Requires a generic integration api call to complete a series of checks for multiple services.
Verifies that all the repositories on the service have branch protection enabled.
Verifies that the service has visible documentation of a particular type and subtype.
Verifies that the service has an owner defined.
Verified that the services has received a deploy within a specified number of days.
Verifies that the service has a repository integrated.
Verifies that the service is maintained though the use of an opslevel.yml service config.
Requires a service owner to manually complete a check for the service.
Requires a payload integration api call to complete a check for the service.
Verifies that the service's repository contains a file with a certain path.
Runs a comprehensive search across the service's repository with advanced search parameters.
Searches the service's repository and verifies if any file matches the given contents.
Verifies that the service has either a dependent or dependency.
Verifies that a service property is set or matches a specified format.
Verifies that the service has the specified tag defined.
Verifies that the service is using a tool of a particular category or name.
Used to ensure **all** filters match for a given resource.
Used to ensure **any** filters match for a given resource.
An email contact method.
A Slack channel contact method.
A Slack handle contact method.
A website contact method.
Consider the time scale of days.
Consider the time scale of months.
Consider the time scale of weeks.
Consider the time scale of years.
Document is an OpenAPI document.
Document is an API document.
Filter by `framework` field.
Filter by group hierarchy.
Filter by `language` field.
Filter by `lifecycle` field.
Filter by `name` field.
Filter by `owner` field.
Filter by `product` field.
Filter by `tags` field.
Filter by `tier` field.
Belongs to a group's hierarchy.
Contains a specific value.
Does not contain a specific value.
Does not equal a specific value.
Specific attribute does not exist.
Ends with a specific value.
Equals a specific value.
Specific attribute exists.
Greater than or equal to a specific value (numeric only).
Less than or equal to a specific value (numeric only).
Matches a value using a regular expression.
Satisfies an expression defined in jq.
Satisfies version constraint (tag value only).
Starts with a specific value.
Job was canceled.
Job run took too long to complete, and was marked as failed.
Job failed during execution.
A pod could not be scheduled for the job in time.
Job was not assigned to a runner for too long.
Job succeded the execution.
translation missing: en.graphql.types.runner_job_outcome_enum.unstarted.
A finished runner job.
A created runner job, but not yet ready to be run.
A runner job ready to be run.
A runner job being run by a runner.
The runner will not actively take jobs.
The runner will process jobs.
Any contact method.
An email contact method.
A Slack channel contact method.
A Slack handle contact method.
A website contact method.
The description of a service.
The primary software development framework of a service.
The primary programming language of a service.
The index of the lifecycle a service belongs to.
The name of a service.
The product that is associated with a service.
The index of the tier a service belongs to.
Used to identify a Repository.
Used to identify a Service.
Used to identify a Team.
No description provided by the author
No description provided by the author
Tools used for administrative purposes.
Tools used as API documentation for this service.
Tools used for source code.
Tools used for building/unit testing a service.
Tools used for deploying changes to a service.
Tools used for tracking/reporting errors.
Tools used for managing feature flags.
Tools used for tracking/reporting the health of a service.
Tools used to surface incidents on a service.
Tools used for tracking issues.
Tools used for displaying logs from services.
Tools used for tracking/reporting service metrics.
Tools used for orchestrating a service.
Tools that do not fit into the available categories.
Tools used for testing the resiliency of a service.
Tools used for managing runbooks for a service.
Tools used for performing security scans.
Tools used for reporting the status of a service.
Tools used as a wiki for this service.
An administrator on the account.
A regular user on the account.

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Encompass CheckCreatePayload and CheckUpdatePayload into 1 struct.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Lightweight Repository struct used to make some API calls return less data.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author

# Type aliases

AlertSourceTypeEnum represents the type of the alert source.
AliasOwnerTypeEnum represents the owner type an alias is assigned to.
ApiDocumentSourceEnum represents the source used to determine the preferred API document.
CheckStatus represents the evaluation status of the check.
CheckType represents the type of check.
ConnectiveEnum represents the logical operator to be used in conjunction with multiple filters (requires filters to be supplied).
ContactType represents the method of contact.
FrequencyTimeScale represents the time scale type for the frequency.
HasDocumentationSubtypeEnum represents the subtype of the document.
HasDocumentationTypeEnum represents the type of the document.
No description provided by the author
No description provided by the author
PredicateKeyEnum represents fields that can be used as part of filter for services.
PredicateTypeEnum represents operations that can be used on predicates.
RunnerJobOutcomeEnum represents the runner job outcome.
RunnerJobStatusEnum represents the runner job status.
RunnerStatusTypeEnum represents The status of an OpsLevel runner.
ContactType represents the method of contact.
ServicePropertyTypeEnum represents properties of services that can be validated.
TaggableResource represents possible types to apply tags to.
No description provided by the author
ToolCategory represents the specific categories that a tool can belong to.
UserRole represents a role that can be assigned to a user.