blob: ad0fab2337d9d2a2ee2a02b6b5d9f79a51d9b7b2 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package service
// This file contains keys used to identify ResultStore Upload API entities as they are
// named and identified in the result store backend. Entity key properties are public
// only to enable JSON serialization. Prefer using getters rather than reading properties
// directly. For more information about ResultStore APIs, see the proto definitions at
// https://github.com/googleapis/googleapis/tree/master/google/devtools/resultstore/v2
import (
api "google.golang.org/genproto/googleapis/devtools/resultstore/v2"
)
// InvocationKey identifies a ResultStore Invocation.
type InvocationKey struct {
EntityID *api.Invocation_Id `json:"id"`
EntityName string `json:"name"`
}
// ID returns the unique ID for the Invocation in ResultStore.
//
// Example: ${INVOCATION_ID} in invocations/${INVOCATION_ID}
func (k InvocationKey) ID() string {
return k.EntityID.InvocationId
}
// Name returns the full name of the Invocation in ResultStore.
//
// Example: invocations/${INVOCATION_ID}
func (k InvocationKey) Name() string {
return k.EntityName
}
// ConfigurationKey identifies a ResultStore Configuration.
type ConfigurationKey struct {
EntityID *api.Configuration_Id `json:"id"`
EntityName string `json:"name"`
}
// ID returns the unique ID for the Configuration in ResultStore.
//
// Example: ${CONFIG_ID} in invocations/${INVOCATION_ID}/configs/${CONFIG_ID}.
func (k ConfigurationKey) ID() string {
return k.EntityID.ConfigurationId
}
// InvocationID returns the Configuration's parent Invocation ID. See InvocationKey for
// docs.
func (k ConfigurationKey) InvocationID() string {
return k.EntityID.InvocationId
}
// Name returns the full name of the Configuration in ResultStore.
//
// Example: invocations/${INVOCATION_ID}/configs/${CONFIG_ID}.
func (k ConfigurationKey) Name() string {
return k.EntityName
}
// TargetKey identifies a ResultStore Target.
type TargetKey struct {
EntityID *api.Target_Id `json:"id"`
EntityName string `json:"name"`
}
// ID returns the unique ID for the Target in ResultStore.
//
// Example: ${TARGET_ID} in invocations/${INVOCATION_ID}/targets/${TARGET_ID}
func (k TargetKey) ID() string {
return k.EntityID.TargetId
}
// InvocationID returns the Target's parent Invocation ID. See InvocationKey for docs.
func (k TargetKey) InvocationID() string {
return k.EntityID.InvocationId
}
// Name returns the full name of the Target in ResultStore.
//
// Example: invocations/${INVOCATION_ID}/targets/${TARGET_ID}.
func (k TargetKey) Name() string {
return k.EntityName
}
// ConfiguredTargetKey identifies a ResultStore ConfiguredTarget.
type ConfiguredTargetKey struct {
EntityID *api.ConfiguredTarget_Id `json:"id"`
EntityName string `json:"name"`
}
// ID returns the unique ID for the ConfiguredTarget in ResultStore. This is the same as
// the configuration ID.
//
// Example: ${CONFIG_ID} in
// invocations/${INVOCATION_ID}/targets/${TARGET_ID}/configuredTargets/${CONFIG_ID}
func (k ConfiguredTargetKey) ID() string {
return k.EntityID.TargetId
}
// InvocationID returns the ConfiguredTarget's parent Invocation ID. See InvocationKey
// for docs.
func (k ConfiguredTargetKey) InvocationID() string {
return k.EntityID.InvocationId
}
// ConfigurationID returns the ConfiguredTarget's Configuration ID. See ConfigurationKey
// for docs.
func (k ConfiguredTargetKey) ConfigurationID() string {
return k.EntityID.ConfigurationId
}
// TargetID returns the ConfiguredTarget's parent Target ID. See TargetKey for docs.
func (k ConfiguredTargetKey) TargetID() string {
return k.EntityID.TargetId
}
// Name returns the full name of the ConfiguredTarget in ResultStore.
//
// Example:
// invocations/${INVOCATION_ID}/targets/${TARGET_ID}/configuredTargets/${CONFIG_ID}
func (k ConfiguredTargetKey) Name() string {
return k.EntityName
}
// ActionKey identifies a ResultStore Action.
type ActionKey struct {
EntityID *api.Action_Id `json:"id"`
EntityName string `json:"name"`
}
// ID returns the unique ID for the Action in ResultStore.
//
// Example: ${ACTION_ID} in
// invocations/${INVOCATION_ID}/targets/${TARGET_ID}/configuredTargets/${CONFIG_ID}/actions/${ACTION_ID}
func (k ActionKey) ID() string {
return k.EntityID.ActionId
}
// InvocationID returns the Action's parent Invocation ID. See InvocationKey for docs.
func (k ActionKey) InvocationID() string {
return k.EntityID.InvocationId
}
// ConfigurationID returns the Action's Configuration ID. See ConfigurationKey for docs.
func (k ActionKey) ConfigurationID() string {
return k.EntityID.ConfigurationId
}
// TargetID returns the Action s's parent Target ID. See TargetKey for docs.
func (k ActionKey) TargetID() string {
return k.EntityID.TargetId
}
// Name returns the full name of the Action in ResultStore.
//
// Example:
// invocations/${INVOCATION_ID}/targets/${TARGET_ID}/configuredTargets/${CONFIG_ID}/actions/${ACTION_ID}
func (k ActionKey) Name() string {
return k.EntityName
}