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

# README

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() {
	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 AliasOwnerTypeEnum as []string.
All CheckStatus as []string.
All CheckType as []string.
All ConnectiveEnum as []string.
All ContactType as []string.
All FrequencyTimeScale as []string.
All PredicateKeyEnum as []string.
All PredicateTypeEnum 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
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

Aliases that are assigned to services.
Aliases that are assigned to teams.
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..
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 the service has an owner defined.
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.
Searches the service's repository and verifies if any file matches the given contents.
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.
Filter by `framework` field.
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.
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.
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.
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 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 managing runbooks for a service.
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
No description provided by the author
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
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
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

# Interfaces

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

# Type aliases

AliasOwnerTypeEnum represents the owner type an alias is assigned to.
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.
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.
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.