converter

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package converter maps between gRPC/proto types and SDK domain types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApproveAllResultFromProto

func ApproveAllResultFromProto(r *pb.ApproveAllDraftChunksResponse) *types.ApproveAllResult

ApproveAllResultFromProto converts a proto ApproveAllDraftChunksResponse to an SDK ApproveAllResult.

func ApproveResultFromProto

func ApproveResultFromProto(r *pb.ApproveDraftChunkResponse) *types.ApproveResult

ApproveResultFromProto converts a proto ApproveDraftChunkResponse to an SDK ApproveResult.

func ClearResultFromProto

func ClearResultFromProto(r *pb.ClearDraftChunksResponse) *types.ClearResult

ClearResultFromProto converts a proto ClearDraftChunksResponse to an SDK ClearResult.

func ConfigUpdateResultFromProto

func ConfigUpdateResultFromProto(resp *pb.UpdateConfigResponse) *v1.ConfigUpdateResult

ConfigUpdateResultFromProto converts an UpdateConfigResponse to an SDK ConfigUpdateResult.

func ConfigUpdateToProto

func ConfigUpdateToProto(cu *v1.ConfigUpdate) (*pb.UpdateConfigRequest, error)

ConfigUpdateToProto converts an SDK ConfigUpdate to an UpdateConfigRequest.

func CopyBoolPtr

func CopyBoolPtr(p *bool) *bool

CopyBoolPtr returns a copy of a *bool pointer. Returns nil for nil input.

func CopyByteSlice

func CopyByteSlice(b []byte) []byte

CopyByteSlice returns a copy of a byte slice. Returns nil for nil input.

func CopyStringMap

func CopyStringMap(m map[string]string) map[string]string

CopyStringMap returns a shallow copy of a string-to-string map. Returns nil for nil input.

func CopyStringSlice

func CopyStringSlice(s []string) []string

CopyStringSlice returns a copy of a string slice. Returns nil for nil input.

func DraftHistoryEntryFromProto

func DraftHistoryEntryFromProto(e *pb.DraftHistoryEntry) *types.DraftHistoryEntry

DraftHistoryEntryFromProto converts a proto DraftHistoryEntry to an SDK DraftHistoryEntry.

func DraftPolicyFromProto

func DraftPolicyFromProto(r *pb.GetDraftPolicyResponse) *types.DraftPolicy

DraftPolicyFromProto converts a proto GetDraftPolicyResponse to an SDK DraftPolicy.

func EffectiveSettingFromProto

func EffectiveSettingFromProto(pv *sbv1.EffectiveSetting) *v1.EffectiveSetting

EffectiveSettingFromProto converts a proto EffectiveSetting to an SDK EffectiveSetting.

func ExecChunkFromEvent

func ExecChunkFromEvent(event *pb.ExecSandboxEvent) (*types.ExecChunk, int, error)

ExecChunkFromEvent converts a proto ExecSandboxEvent to an ExecChunk and/or exit code. For stdout/stderr events, returns the chunk with exitCode -1. For exit events, returns nil chunk with the exit code.

func ExecInteractiveRequestToProto

func ExecInteractiveRequestToProto(sandboxID string, command []string, cols, rows uint32, opts *types.ExecOptions) *pb.ExecSandboxRequest

ExecInteractiveRequestToProto builds a proto ExecSandboxRequest for Interactive mode.

func ExecRequestToProto

func ExecRequestToProto(sandboxID string, command []string, opts *types.ExecOptions) *pb.ExecSandboxRequest

ExecRequestToProto builds a proto ExecSandboxRequest for Run/Stream modes.

func ExecResultFromEvents

func ExecResultFromEvents(events []*pb.ExecSandboxEvent) (*types.ExecResult, error)

ExecResultFromEvents collects a sequence of ExecSandboxEvents into an ExecResult.

func FromGRPCError

func FromGRPCError(err error) error

FromGRPCError converts a gRPC error to a typed StatusError. Returns nil for nil errors and OK status. Non-gRPC errors pass through unchanged.

func GatewayConfigFromProto

func GatewayConfigFromProto(resp *sbv1.GetGatewayConfigResponse) *v1.GatewayConfig

GatewayConfigFromProto converts a GetGatewayConfigResponse to an SDK GatewayConfig.

func LogLineFromProto

func LogLineFromProto(l *pb.SandboxLogLine) *types.LogLine

LogLineFromProto converts a proto SandboxLogLine to an SDK LogLine.

func LogResultFromProto

func LogResultFromProto(r *pb.GetSandboxLogsResponse) *types.LogResult

LogResultFromProto converts a proto GetSandboxLogsResponse to an SDK LogResult.

func MillisFromTime

func MillisFromTime(t time.Time) int64

MillisFromTime converts a time.Time to a millisecond epoch timestamp. A zero time returns 0.

func NetworkBinaryFromProto

func NetworkBinaryFromProto(b *sbv1.NetworkBinary) *types.NetworkBinary

NetworkBinaryFromProto converts a proto NetworkBinary to an SDK NetworkBinary.

func NetworkBinaryToProto

func NetworkBinaryToProto(b *types.NetworkBinary) *sbv1.NetworkBinary

NetworkBinaryToProto converts an SDK NetworkBinary to a proto NetworkBinary.

func NetworkEndpointFromProto

func NetworkEndpointFromProto(ep *sbv1.NetworkEndpoint) *types.NetworkEndpoint

NetworkEndpointFromProto converts a proto NetworkEndpoint to an SDK NetworkEndpoint. Only Host, Port, and Protocol are mapped; additional proto fields are ignored.

func NetworkEndpointToProto

func NetworkEndpointToProto(ep *types.NetworkEndpoint) *sbv1.NetworkEndpoint

NetworkEndpointToProto converts an SDK NetworkEndpoint to a proto NetworkEndpoint.

func NetworkPolicyRuleFromProto

func NetworkPolicyRuleFromProto(r *sbv1.NetworkPolicyRule) *types.NetworkPolicyRule

NetworkPolicyRuleFromProto converts a proto NetworkPolicyRule to an SDK NetworkPolicyRule.

func NetworkPolicyRuleToProto

func NetworkPolicyRuleToProto(r *types.NetworkPolicyRule) *sbv1.NetworkPolicyRule

NetworkPolicyRuleToProto converts an SDK NetworkPolicyRule to a proto NetworkPolicyRule.

func PolicyChunkFromProto

func PolicyChunkFromProto(c *pb.PolicyChunk) *types.PolicyChunk

PolicyChunkFromProto converts a proto PolicyChunk to an SDK PolicyChunk.

func PolicyLoadStatusFromProto

func PolicyLoadStatusFromProto(s pb.PolicyStatus) types.PolicyLoadStatus

PolicyLoadStatusFromProto converts a proto PolicyStatus to an SDK PolicyLoadStatus.

func PolicyLoadStatusToProto

func PolicyLoadStatusToProto(s types.PolicyLoadStatus) pb.PolicyStatus

PolicyLoadStatusToProto converts an SDK PolicyLoadStatus to a proto PolicyStatus.

func PolicyMergeOperationToProto

func PolicyMergeOperationToProto(op *v1.PolicyMergeOperation) (*pb.PolicyMergeOperation, error)

PolicyMergeOperationToProto converts an SDK PolicyMergeOperation to a proto PolicyMergeOperation. Exactly one of the pointer fields must be non-nil. Returns an error if zero or multiple are set.

func PolicySourceFromProto

func PolicySourceFromProto(ps sbv1.PolicySource) v1.PolicySource

PolicySourceFromProto converts a proto PolicySource enum to an SDK PolicySource.

func PolicyStatusResultFromProto

func PolicyStatusResultFromProto(r *pb.GetSandboxPolicyStatusResponse) *types.PolicyStatusResult

PolicyStatusResultFromProto converts a proto GetSandboxPolicyStatusResponse to an SDK PolicyStatusResult.

func ProfileCategoryFromProto

func ProfileCategoryFromProto(c pb.ProviderProfileCategory) types.ProfileCategory

ProfileCategoryFromProto converts a proto ProviderProfileCategory to an SDK ProfileCategory.

func ProfileCategoryToProto

func ProfileCategoryToProto(c types.ProfileCategory) pb.ProviderProfileCategory

ProfileCategoryToProto converts an SDK ProfileCategory to a proto ProviderProfileCategory.

func ProfileCredentialFromProto

func ProfileCredentialFromProto(c *pb.ProviderProfileCredential) *types.ProfileCredential

ProfileCredentialFromProto converts a proto ProviderProfileCredential to an SDK ProfileCredential. The SDK maps 4 fields from the 10-field proto: Name, Description, Required, and Secret. Secret is derived from whether the proto has a Refresh configuration.

func ProfileCredentialToProto

func ProfileCredentialToProto(c *types.ProfileCredential) *pb.ProviderProfileCredential

ProfileCredentialToProto converts an SDK ProfileCredential to a proto ProviderProfileCredential. Only Name, Description, and Required are mapped. Secret is not round-trippable because it is derived from the Refresh field in the proto.

func ProfileDiagnosticFromProto

func ProfileDiagnosticFromProto(d *pb.ProviderProfileDiagnostic) *types.ProfileDiagnostic

ProfileDiagnosticFromProto converts a proto ProviderProfileDiagnostic to an SDK ProfileDiagnostic.

func ProfileImportItemFromProto

func ProfileImportItemFromProto(item *pb.ProviderProfileImportItem) *types.ProfileImportItem

ProfileImportItemFromProto converts a proto ProviderProfileImportItem to an SDK ProfileImportItem.

func ProfileImportItemToProto

func ProfileImportItemToProto(item *types.ProfileImportItem) *pb.ProviderProfileImportItem

ProfileImportItemToProto converts an SDK ProfileImportItem to a proto ProviderProfileImportItem.

func ProviderFromProto

func ProviderFromProto(p *dm.Provider) *types.Provider

ProviderFromProto converts a proto Provider to an SDK Provider.

func ProviderProfileFromProto

func ProviderProfileFromProto(p *pb.ProviderProfile) *types.ProviderProfile

ProviderProfileFromProto converts a proto ProviderProfile to an SDK ProviderProfile.

func ProviderProfileToProto

func ProviderProfileToProto(p *types.ProviderProfile) *pb.ProviderProfile

ProviderProfileToProto converts an SDK ProviderProfile to a proto ProviderProfile.

func ProviderToProto

func ProviderToProto(p *types.Provider) *dm.Provider

ProviderToProto converts an SDK Provider to a proto Provider.

func RefreshConfigToProto

func RefreshConfigToProto(c *types.RefreshConfig) *pb.ConfigureProviderRefreshRequest

RefreshConfigToProto converts an SDK RefreshConfig to a proto ConfigureProviderRefreshRequest. Material and SecretMaterialKeys are deep-copied.

func RefreshStatusFromProto

func RefreshStatusFromProto(s *pb.ProviderCredentialRefreshStatus) *types.RefreshStatus

RefreshStatusFromProto converts a proto ProviderCredentialRefreshStatus to an SDK RefreshStatus.

func RefreshStrategyFromProto

func RefreshStrategyFromProto(s pb.ProviderCredentialRefreshStrategy) types.RefreshStrategy

RefreshStrategyFromProto converts a proto ProviderCredentialRefreshStrategy to an SDK RefreshStrategy.

func RefreshStrategyToProto

RefreshStrategyToProto converts an SDK RefreshStrategy to a proto ProviderCredentialRefreshStrategy.

func SSHSessionFromProto

func SSHSessionFromProto(resp *pb.CreateSshSessionResponse) *v1.SSHSession

SSHSessionFromProto converts a CreateSshSessionResponse to an SSHSession.

func SSHSessionToProto

func SSHSessionToProto(session *v1.SSHSession) *pb.CreateSshSessionResponse

SSHSessionToProto converts an SSHSession to a CreateSshSessionResponse. This is primarily used for round-trip testing and fake implementations.

func SandboxConfigFromProto

func SandboxConfigFromProto(resp *sbv1.GetSandboxConfigResponse) *v1.SandboxConfig

SandboxConfigFromProto converts a GetSandboxConfigResponse to an SDK SandboxConfig.

func SandboxFromProto

func SandboxFromProto(s *pb.Sandbox) *types.Sandbox

SandboxFromProto converts a proto Sandbox to an SDK Sandbox.

func SandboxPhaseFromProto

func SandboxPhaseFromProto(phase pb.SandboxPhase) types.SandboxPhase

SandboxPhaseFromProto converts a proto SandboxPhase to an SDK SandboxPhase.

func SandboxPhaseToProto

func SandboxPhaseToProto(phase types.SandboxPhase) pb.SandboxPhase

SandboxPhaseToProto converts an SDK SandboxPhase to a proto SandboxPhase.

func SandboxPolicyFromProto added in v0.2.1

func SandboxPolicyFromProto(p *sbv1.SandboxPolicy) *types.SandboxPolicy

SandboxPolicyFromProto converts a proto SandboxPolicy to an SDK SandboxPolicy. Returns nil for nil input. All slice and map fields are deep-copied.

func SandboxPolicyRevisionFromProto

func SandboxPolicyRevisionFromProto(r *pb.SandboxPolicyRevision) *types.SandboxPolicyRevision

SandboxPolicyRevisionFromProto converts a proto SandboxPolicyRevision to an SDK SandboxPolicyRevision.

func SandboxPolicyToProto added in v0.2.1

func SandboxPolicyToProto(p *types.SandboxPolicy) *sbv1.SandboxPolicy

SandboxPolicyToProto converts an SDK SandboxPolicy to a proto SandboxPolicy. Returns nil for nil input. All slice and map fields are deep-copied.

func SandboxSpecToProto

func SandboxSpecToProto(spec *types.SandboxSpec) *pb.SandboxSpec

SandboxSpecToProto converts an SDK SandboxSpec to a proto SandboxSpec.

func SandboxToProto

func SandboxToProto(s *types.Sandbox) *pb.Sandbox

SandboxToProto converts an SDK Sandbox to a proto Sandbox.

func ServiceEndpointFromProto

func ServiceEndpointFromProto(resp *pb.ServiceEndpointResponse) *types.ServiceEndpoint

ServiceEndpointFromProto converts a proto ServiceEndpointResponse to an SDK ServiceEndpoint. The response flattens the nested Endpoint and top-level URL into a single SDK type.

func ServiceEndpointToProto

func ServiceEndpointToProto(se *types.ServiceEndpoint) *pb.ServiceEndpointResponse

ServiceEndpointToProto converts an SDK ServiceEndpoint to a proto ServiceEndpointResponse.

func SettingScopeFromProto

func SettingScopeFromProto(ps sbv1.SettingScope) v1.SettingScope

SettingScopeFromProto converts a proto SettingScope enum to an SDK SettingScope.

func SettingScopeToProto

func SettingScopeToProto(s v1.SettingScope) sbv1.SettingScope

SettingScopeToProto converts an SDK SettingScope to a proto SettingScope enum.

func SettingValueFromProto

func SettingValueFromProto(pv *sbv1.SettingValue) *v1.SettingValue

SettingValueFromProto converts a proto SettingValue (oneof) to an SDK SettingValue.

func SettingValueToProto

func SettingValueToProto(sv *v1.SettingValue) *sbv1.SettingValue

SettingValueToProto converts an SDK SettingValue to a proto SettingValue (oneof).

func TimeFromMillis

func TimeFromMillis(ms int64) time.Time

TimeFromMillis converts a millisecond epoch timestamp to time.Time. A zero value returns the zero time.

func UndoResultFromProto

func UndoResultFromProto(r *pb.UndoDraftChunkResponse) *types.UndoResult

UndoResultFromProto converts a proto UndoDraftChunkResponse to an SDK UndoResult.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL