{"modulePath":"github.com/openshift-hyperfleet/hyperfleet-api","version":"v0.4.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package services\n\n## Constants\n\n```go\nconst (\n\tConditionValidationErrorMissing = \"missing\"\n)\n```\nCondition validation error type\n\n## Functions\n\n```go\nfunc AdapterObservedTime(as *api.AdapterStatus) time.Time\n```\nAdapterObservedTime returns the adapter-reported observation instant used for ordering and aggregation.\n\n```go\nfunc AggregateResourceStatus(ctx context.Context, in AggregateResourceStatusInput) (\n\treconciled, lastKnownReconciled api.ResourceCondition, adapterConditions []api.ResourceCondition,\n)\n```\nAggregateResourceStatus computes Reconciled, LastKnownReconciled, and per-adapter conditions from stored adapter rows and previous conditions. It does not use wall clock.\n\nThe returned adapterConditions slice contains one entry per required adapter that has reported, with a type derived from the adapter name (e.g. \"adapter1\" → \"Adapter1Successful\").\n\n```go\nfunc ValidateMandatoryConditions(conditions []api.AdapterCondition) (errorType, conditionName string)\n```\nValidateMandatoryConditions checks if all mandatory conditions are present. Format validation (empty type, duplicates, invalid status) is done in the Handler layer.\n\n## Types\n\n```go\ntype AdapterStatusService interface {\n\tGet(ctx context.Context, id string) (*api.AdapterStatus, *errors.ServiceError)\n\tCreate(ctx context.Context, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError)\n\tUpsert(ctx context.Context, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError)\n\tDelete(ctx context.Context, id string) *errors.ServiceError\n\tFindByResource(\n\t\tctx context.Context, resourceType, resourceID string,\n\t) (api.AdapterStatusList, *errors.ServiceError)\n\tFindByResourcePaginated(\n\t\tctx context.Context, resourceType, resourceID string, listArgs *ListArguments,\n\t) (api.AdapterStatusList, int64, *errors.ServiceError)\n\tFindByResourceAndAdapter(\n\t\tctx context.Context, resourceType, resourceID, adapter string,\n\t) (*api.AdapterStatus, *errors.ServiceError)\n}\n```\n\n```go\nfunc NewAdapterStatusService(adapterStatusDao dao.AdapterStatusDao) AdapterStatusService\n```\n\n```go\ntype AggregateResourceStatusInput struct {\n\tResourceGeneration int32\n\tRefTime            time.Time\n\tDeletedTime        *time.Time\n\tPrevConditionsJSON []byte\n\tRequiredAdapters   []string\n\tAdapterStatuses    api.AdapterStatusList\n\tHasChildResources  bool\n}\n```\nAggregateResourceStatusInput carries everything needed to compute deterministic conditions. RefTime must be resource.updated\\_time (never time.Now) so results are reproducible.\n\n```go\ntype ApplyInput struct {\n\tAdapterStatuses api.AdapterStatusList\n\tResource        interface{}\n\tRefTime         time.Time\n\t// PrevConditions is the previous mapped conditions from resource.Conditions\n\t// Used to preserve CreatedTime and LastTransitionTime (matching aggregation.go pattern)\n\tPrevConditions []api.ResourceCondition\n}\n```\nApplyInput holds the input data for condition mapping\n\n```go\ntype ConditionMapper struct {\n\t// contains filtered or unexported fields\n}\n```\nConditionMapper evaluates CEL-based condition mapping rules\n\n```go\nfunc NewConditionMapper(resourceKind string, rules []registry.ConditionMappingRule) (*ConditionMapper, error)\n```\nNewConditionMapper creates a new condition mapper with pre-compiled rules\n\n```go\nfunc (m *ConditionMapper) Apply(ctx context.Context, input ApplyInput) ([]api.ResourceCondition, error)\n```\nApply evaluates mapping rules and returns mapped conditions. Returns error on CEL evaluation failure to trigger transaction rollback per design doc. This ensures timely retry (10s) instead of delayed retry (30min) that would occur if partial results were committed without mapped conditions.\n\n```go\ntype GenericService interface {\n\tList(\n\t\tctx context.Context, args *ListArguments, resourceList interface{},\n\t) (*api.PagingMeta, *errors.ServiceError)\n}\n```\n\n```go\nfunc NewGenericService(genericDao dao.GenericDao) GenericService\n```\n\n```go\ntype ListArguments struct {\n\tSearch      string\n\tRefType     string\n\tRefTargetID string\n\tPreloads    []string\n\tOrder       []string\n\tFields      []string\n\tSize        int64\n\tPage        int64\n}\n```\nListArguments are arguments relevant for listing objects. This struct is common to all service List funcs in this package\n\n```go\nfunc NewListArguments() *ListArguments\n```\n\n```go\ntype ResourceService interface {\n\tGet(ctx context.Context, kind, id string) (*api.Resource, *errors.ServiceError)\n\tCreate(ctx context.Context, kind string, resource *api.Resource, refs api.ReferenceMap) (*api.Resource, *errors.ServiceError) //nolint:lll\n\tPatch(ctx context.Context, kind, id string, patch *api.ResourcePatch) (*api.Resource, *errors.ServiceError)\n\tDelete(ctx context.Context, kind, id string) (*api.Resource, *errors.ServiceError)\n\tList(ctx context.Context, kind string, args *ListArguments) (api.ResourceList, *api.PagingMeta, *errors.ServiceError)\n\tGetByOwner(ctx context.Context, kind, id, ownerID string) (*api.Resource, *errors.ServiceError)\n\tListByOwner(ctx context.Context, kind, ownerID string, args *ListArguments) (api.ResourceList, *api.PagingMeta, *errors.ServiceError) // nolint:lll\n\tForceDelete(ctx context.Context, kind, id, reason string) *errors.ServiceError\n\tGetByID(ctx context.Context, id string) (*api.Resource, *errors.ServiceError)\n\tListAll(ctx context.Context, args *ListArguments) (api.ResourceList, *api.PagingMeta, *errors.ServiceError)\n\tProcessAdapterStatus(ctx context.Context, kind, resourceID string, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError) // nolint:lll\n}\n```\n\n```go\nfunc NewResourceService(\n\tresourceDao dao.ResourceDao,\n\tresourceLabelDao dao.ResourceLabelDao,\n\tadapterStatusDao dao.AdapterStatusDao,\n\tresourceConditionDao dao.ResourceConditionDao,\n\tgeneric GenericService,\n) (ResourceService, error)\n```\n\n","path":"github.com/openshift-hyperfleet/hyperfleet-api/pkg/services","name":"services","synopsis":"","isRedistributable":true}
