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

# README

Overall

opslevel-go

Package opslevel provides an OpsLevel API client implementation.

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 RunnerJobOutcomeEnum as []string.
All RunnerJobStatusEnum as []string.
All RunnerStatusTypeEnum 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
Validates resource's `validate:""` struct tags.
Get JSON formatted string of an OpsLevel resource - also sets defaults.
No description provided by the author
No description provided by the author
Deprecated: Use NewGQLClient instead.
Make new OpsLevel resource with defaults set.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Apply resource's `default:""` struct tags.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Generate yaml formatted string of an OpsLevel resource - also sets defaults.

# Constants

Monitor is reporting an alert.
Monitor currently being updated.
No data received yet.
Monitor is not reporting any warnings or alerts.
Monitor is reporting a warning.
A Datadog alert source (aka monitor).
A New Relic alert source (aka service).
An Opsgenie alert source (aka service).
A PagerDuty alert source (aka service).
Aliases that are assigned to domains.
Aliases that are assigned to groups.
Aliases that are assigned to infrastructure resources.
Aliases that are assigned to scorecards.
Aliases that are assigned to services.
Aliases that are assigned to systems.
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.
Does not equal a specific value.
Equals a specific value.
Filter by `id` of campaign.
Filter by campaign owner.
Filter by campaign status.
Notification will be sent via email.
Notification will be sent by slack.
Service is failing one or more checks in the campaign.
Service is passing all the checks in the campaign.
Sort by number of `checks passing` ascending.
Sort by number of `checks passing` descending.
Sort by `endedDate` ascending.
Sort by `endedDate` descending.
Sort by `filter` ascending.
Sort by `filter` descending.
Sort by `name` ascending.
Sort by `name` descending.
Sort by `owner` ascending.
Sort by `owner` descending.
Sort by number of `services complete` ascending.
Sort by number of `services complete` descending.
Sort by `startDate` ascending.
Sort by `startDate` descending.
Sort by `status` ascending.
Sort by `status` descending.
Sort by `targetDate` ascending.
Sort by `targetDate` descending.
Campaign is delayed.
Campaign has been created but is not yet active.
Campaign ended.
Campaign is in progress.
Campaign has been scheduled to begin in the future.
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.
Quickly scan the service’s repository for the existence or contents of a specific file.
Run a comprehensive search across the service's repository using advanced search parameters.
Quickly search the service’s repository for specific contents in any file.
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 GitHub handle.
A Slack channel contact method.
A Slack handle contact method.
A website contact method.
A custom action associated with the global scope (no particular entity type).
A custom action associated with services.
An HTTP DELETE request.
An HTTP GET request.
An HTTP PATCH request.
An HTTP POST request.
An HTTP PUT request.
Admin users.
All users of OpsLevel.
The owners of a service.
The action failed to complete.
A result has not been determined.
The action completed succesfully.
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.
Document is an Tech document.
Order by `created_at` ascending.
Order by `created_at` descending.
Order by `processed_at` ascending.
Order by `processed_at` descending.
Filter by Alias attached to this service, if any.
Filter by the creation source.
Filter by Domain that includes the System this service is assigned to, if any.
Filter by another filter.
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 `owner` hierarchy.
Filter by `product` field.
Filter by Repository that this service is attached to, if any.
Filter by System that this service is assigned to, if any.
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.
A certain filter is not matched.
Does not match a value using a regular expression.
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).
A certain filter is matched.
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 resource belongs to the node on the edge.
The resource contains the node on the edge.
The resource is a dependency of the node on the edge.
The resource depends on the node on the edge.
The source resource belongs to the target resource.
The source resource depends on the target resource.
Repositories that are only accessible to organization users.
Repositories that are private to the user.
Repositories that are publically accessible.
Document is hidden.
Document is pinned.
Document is visible.
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.
Order by whether or not the checks on the scorecard affect the overall maturity, in ascending order.
Order by whether or not the checks on the scorecard affect the overall maturity, in descending order.
Order by the associated filter's name, in ascending order.
Order by the associated filter's name, in descending order.
Order by the scorecard's name, in ascending order.
Order by the scorecard's name, in descending order.
Order by the scorecard owner's name, in ascending order.
Order by the scorecard owner's name, in descending order.
Order by the fraction of passing checks on the scorecard, in ascending order.
Order by the fraction of passing checks on the scorecard, in descending order.
Order by the number of services covered by the scorecard, in ascending order.
Order by the number of services covered by the scorecard, in descending order.
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.
Additional information about the service.
The product that is associated with a service.
The system that the service belongs to.
The index of the tier a service belongs to.
Sort by alert status ascending.
Sort by alert status descending.
Sort by `checks_passing` ascending.
Sort by `checks_passing` descending.
Sort by last deploy time ascending.
Sort by last deploy time descending.
Sort by level ascending.
Sort by level descending.
Sort by lifecycle ascending.
Sort by lifecycle descending.
Sort by `name` ascending.
Sort by `name` descending.
Sort by `owner` ascending.
Sort by `owner` descending.
Sort by `product` ascending.
Sort by `product` descending.
Alias to sort by `checks_passing` ascending.
Alias to sort by `checks_passing` descending.
Sort by `tier` ascending.
Sort by `tier` descending.
Used to identify a Domain.
Used to identify an Infrastructure Resource.
Used to identify a Repository.
Used to identify a Service.
Used to identify a System.
Used to identify a Team.
Used to identify a User.
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 diagramming architecture.
Tools used for tracking issues.
Tools used for source code.
Tools used for building/unit testing a service.
Tools used for deploying changes to a service.
Tools used for documenting design.
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 observability.
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 basic user on the account with limited access.
A regular user on the account.
Filter by the `deactivated_at` field.
Filter by `email` field.
Filter by the `last_sign_in_at` field.
Filter by `name` field.
Filter by `role` field.
Filter by `tags` belonging to user.
Sort by slug ascending.
Sort by slug descending.
Sort by updated_at ascending.
Sort by updated_at descending.

# Variables

All AlertSourceStatusTypeEnum as []string.
All AlertSourceTypeEnum as []string.
All AliasOwnerTypeEnum as []string.
All ApiDocumentSourceEnum as []string.
All BasicTypeEnum as []string.
All CampaignFilterEnum as []string.
All CampaignReminderTypeEnum as []string.
All CampaignServiceStatusEnum as []string.
All CampaignSortEnum as []string.
All CampaignStatusEnum as []string.
All CheckStatus as []string.
All CheckType as []string.
All ConnectiveEnum as []string.
All ContactType as []string.
All CustomActionsEntityTypeEnum as []string.
All CustomActionsHttpMethodEnum as []string.
All CustomActionsTriggerDefinitionAccessControlEnum as []string.
All CustomActionsTriggerEventStatusEnum as []string.
All FrequencyTimeScale as []string.
All HasDocumentationSubtypeEnum as []string.
All HasDocumentationTypeEnum as []string.
All PayloadSortEnum as []string.
All PredicateKeyEnum as []string.
All PredicateTypeEnum as []string.
All RelatedResourceRelationshipTypeEnum as []string.
All RelationshipTypeEnum as []string.
All RepositoryVisibilityEnum as []string.
All ResourceDocumentStatusTypeEnum as []string.
All ScorecardSortEnum as []string.
All ServicePropertyTypeEnum as []string.
All ServiceSortEnum as []string.
All TaggableResource as []string.
All ToolCategory as []string.
All UserRole as []string.
All UsersFilterEnum as []string.
All VaultSecretsSortEnum as []string.
No description provided by the author
No description provided by the author
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
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
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
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
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
Has no json struct tags as this is nested in returned data structs.
Had to create this to prevent circular references on User because Team has UserConnection.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
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
No description provided by the author

# Type aliases

AlertSourceStatusTypeEnum represents the monitor status level.
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.
BasicTypeEnum represents operations that can be used on filters.
CampaignFilterEnum represents fields that can be used as part of filter for campaigns.
CampaignReminderTypeEnum represents type/Format of the notification.
CampaignServiceStatusEnum represents status of whether a service is passing all checks for a campaign or not.
CampaignSortEnum represents sort possibilities for campaigns.
CampaignStatusEnum represents the campaign status.
No description provided by the author
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.
CustomActionsEntityTypeEnum represents the entity types a custom action can be associated with.
CustomActionsHttpMethodEnum represents an HTTP request method.
CustomActionsTriggerDefinitionAccessControlEnum represents who can see and use the trigger definition.
CustomActionsTriggerEventStatusEnum represents the status of the custom action trigger event.
No description provided by the author
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
JSON is a specialized map[string]string to support proper graphql serialization.
JSONString is a specialized input type to support serialization to JSON for input to graphql.
No description provided by the author
PayloadSortEnum represents sort possibilities for payloads.
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.
RelatedResourceRelationshipTypeEnum represents the type of the relationship between two resources.
RelationshipTypeEnum represents the type of relationship between two resources.
RepositoryVisibilityEnum represents possible visibility levels for repositories.
ResourceDocumentStatusTypeEnum represents status of a document on a resource.
RunnerJobOutcomeEnum represents the runner job outcome.
RunnerJobStatusEnum represents the runner job status.
RunnerStatusTypeEnum represents The status of an OpsLevel runner.
ScorecardSortEnum represents the possible options to sort the resulting list of scorecards.
ServicePropertyTypeEnum represents properties of services that can be validated.
ServiceSortEnum represents sort possibilities for services.
No description provided by the author
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.
UsersFilterEnum represents fields that can be used as part of filter for users.
VaultSecretsSortEnum represents sort possibilities for secrets.