{"modulePath":"github.com/agentshield-dev/agentshield","version":"v0.0.1-rc.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\nPackage api decodes Kubernetes objects from their unstructured transport form into typed values for projection. Core and networking kinds use the upstream k8s.io/api types; Gateway API kinds use local subsets that decode only the fields projection interprets.\n\n## Types\n\n```go\ntype AllowedRoutes struct {\n\tNamespaces *RouteNamespaces `json:\"namespaces,omitempty\"`\n}\n```\nAllowedRoutes limits which namespaces may attach routes to a listener.\n\n```go\ntype BackendReference struct {\n\tGroup     string            `json:\"group,omitempty\"`\n\tKind      string            `json:\"kind,omitempty\"`\n\tNamespace string            `json:\"namespace,omitempty\"`\n\tName      string            `json:\"name\"`\n\tPort      *int32            `json:\"port,omitempty\"`\n\tWeight    *int32            `json:\"weight,omitempty\"`\n\tFilters   []json.RawMessage `json:\"filters,omitempty\"`\n}\n```\nBackendReference names one route backend, by default a Service.\n\n```go\ntype Decoded[T any] struct {\n\tValue    T\n\tSpecJSON json.RawMessage\n}\n```\nDecoded wraps a typed object and, when present, its raw spec. The raw spec feeds configuration digests so fields the typed form omits still change the digest.\n\n```go\nfunc Decode[T any](object *unstructured.Unstructured) (Decoded[T], error)\n```\nDecode round-trips object through JSON into T and captures the raw spec. Unknown fields are ignored; a field with the wrong JSON type is an error.\n\n```go\nfunc Deployment(object *unstructured.Unstructured) (Decoded[appsv1.Deployment], error)\n```\nDeployment decodes an apps/v1 Deployment.\n\n```go\nfunc GatewayObject(object *unstructured.Unstructured) (Decoded[Gateway], error)\n```\nGatewayObject decodes a Gateway.\n\n```go\nfunc HTTPRouteObject(object *unstructured.Unstructured) (Decoded[HTTPRoute], error)\n```\nHTTPRouteObject decodes an HTTPRoute.\n\n```go\nfunc Ingress(object *unstructured.Unstructured) (Decoded[networkingv1.Ingress], error)\n```\nIngress decodes a networking.k8s.io/v1 Ingress.\n\n```go\nfunc NetworkPolicy(object *unstructured.Unstructured) (Decoded[networkingv1.NetworkPolicy], error)\n```\nNetworkPolicy decodes a networking.k8s.io/v1 NetworkPolicy.\n\n```go\nfunc Node(object *unstructured.Unstructured) (Decoded[corev1.Node], error)\n```\nNode decodes a core/v1 Node.\n\n```go\nfunc Pod(object *unstructured.Unstructured) (Decoded[corev1.Pod], error)\n```\nPod decodes a core/v1 Pod.\n\n```go\nfunc Service(object *unstructured.Unstructured) (Decoded[corev1.Service], error)\n```\nService decodes a core/v1 Service.\n\n```go\ntype Gateway struct {\n\tmetav1.TypeMeta   `json:\",inline\"`\n\tmetav1.ObjectMeta `json:\"metadata,omitempty\"`\n\tSpec              GatewaySpec   `json:\"spec,omitempty\"`\n\tStatus            GatewayStatus `json:\"status,omitempty\"`\n}\n```\nGateway is the decoded subset of a gateway.networking.k8s.io/v1 Gateway.\n\n```go\ntype GatewayListener struct {\n\tName          string          `json:\"name\"`\n\tPort          int32           `json:\"port\"`\n\tProtocol      string          `json:\"protocol\"`\n\tAllowedRoutes *AllowedRoutes  `json:\"allowedRoutes,omitempty\"`\n\tTLS           json.RawMessage `json:\"tls,omitempty\"`\n\tHostname      *string         `json:\"hostname,omitempty\"`\n}\n```\nGatewayListener is one Gateway listener.\n\n```go\ntype GatewaySpec struct {\n\tGatewayClassName string            `json:\"gatewayClassName\"`\n\tAddresses        []json.RawMessage `json:\"addresses,omitempty\"`\n\tListeners        []GatewayListener `json:\"listeners,omitempty\"`\n}\n```\nGatewaySpec decodes the class, listeners, and requested addresses.\n\n```go\ntype GatewayStatus struct {\n\tAddresses  []json.RawMessage  `json:\"addresses,omitempty\"`\n\tListeners  []json.RawMessage  `json:\"listeners,omitempty\"`\n\tConditions []metav1.Condition `json:\"conditions,omitempty\"`\n}\n```\nGatewayStatus holds controller-reported addresses and conditions. They are observed controller state, not proof of reachability.\n\n```go\ntype HTTPRoute struct {\n\tmetav1.TypeMeta   `json:\",inline\"`\n\tmetav1.ObjectMeta `json:\"metadata,omitempty\"`\n\tSpec              HTTPRouteSpec   `json:\"spec,omitempty\"`\n\tStatus            HTTPRouteStatus `json:\"status,omitempty\"`\n}\n```\nHTTPRoute is the decoded subset of a gateway.networking.k8s.io/v1 HTTPRoute.\n\n```go\ntype HTTPRouteRule struct {\n\tMatches     []json.RawMessage  `json:\"matches,omitempty\"`\n\tFilters     []json.RawMessage  `json:\"filters,omitempty\"`\n\tBackendRefs []BackendReference `json:\"backendRefs,omitempty\"`\n}\n```\nHTTPRouteRule holds one rule's backends. Matches and filters stay raw for digests and are not interpreted.\n\n```go\ntype HTTPRouteSpec struct {\n\tHostnames  []string          `json:\"hostnames,omitempty\"`\n\tParentRefs []ParentReference `json:\"parentRefs,omitempty\"`\n\tRules      []HTTPRouteRule   `json:\"rules,omitempty\"`\n}\n```\nHTTPRouteSpec decodes hostnames, parent references, and backend rules.\n\n```go\ntype HTTPRouteStatus struct {\n\tParents []json.RawMessage `json:\"parents,omitempty\"`\n}\n```\nHTTPRouteStatus holds raw per-parent status entries.\n\n```go\ntype ParentReference struct {\n\tGroup       string `json:\"group,omitempty\"`\n\tKind        string `json:\"kind,omitempty\"`\n\tNamespace   string `json:\"namespace,omitempty\"`\n\tName        string `json:\"name\"`\n\tSectionName string `json:\"sectionName,omitempty\"`\n\tPort        *int32 `json:\"port,omitempty\"`\n}\n```\nParentReference names a Gateway or other parent a route attaches to.\n\n```go\ntype RouteNamespaces struct {\n\tFrom     string                `json:\"from,omitempty\"`\n\tSelector *metav1.LabelSelector `json:\"selector,omitempty\"`\n}\n```\nRouteNamespaces is the namespace policy for route attachment.\n\n","path":"github.com/agentshield-dev/agentshield/plugins/kubernetes/api","name":"api","synopsis":"Package api decodes Kubernetes objects from their unstructured transport form into typed values for projection.","isRedistributable":true}
