dataapi

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0, BSD-3-Clause Imports: 32 Imported by: 2

Documentation

Overview

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	ATHENS_EUROPE_TZ = "Europe/Athens"
	DEFAULT_OFFSET   = "UTC+2:00"
	DTGR_PARTNER_ID  = "dt-gr"
	GR_PREFIX        = "GR"
)

Variables

This section is empty.

Functions

func AddCertExpiryToContextMap

func AddCertExpiryToContextMap(contextMap map[string]string, clientCertExpiry string)

func AddClientCertDurationToContext

func AddClientCertDurationToContext(contextMap map[string]string, clientCertExpiryStr string)

func AddClientProtocolToContextMap

func AddClientProtocolToContextMap(contextMap map[string]string, clientProtocolHeader string)

func AddContextForPods

func AddContextForPods(ws *xhttp.XconfServer, contextMap map[string]string, satToken string, vargs ...log.Fields) (*PodData, *AccountServiceData)

func AddContextFromTaggingService

func AddContextFromTaggingService(ws *xhttp.XconfServer, contextMap map[string]string, satToken string, configSetHash string, isRfcApi bool, vargs ...log.Fields) []string

func AddEstbFirmwareContext

func AddEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap map[string]string, usePartnerAppType bool, shouldAddIp bool, vargs ...log.Fields) error

AddEstbFirmwareContext ..

func AddFeatureControlContext

func AddFeatureControlContext(ws *xhttp.XconfServer, r *http.Request, contextMap map[string]string, configSetHash string, vargs ...log.Fields) (*PodData, []string, *AccountServiceData)

AddFeatureControlContext ..

func AddGroupServiceContext

func AddGroupServiceContext(ws *xhttp.XconfServer, contextMap map[string]string, macKeyName string, fields log.Fields)

func AddGroupServiceFTContext

func AddGroupServiceFTContext(ws *xhttp.XconfServer, macAddressKey string, contextMap map[string]string, checkForGroups bool, fields log.Fields) []string

func AddGroupServiceFeatureTags

func AddGroupServiceFeatureTags(ws *xhttp.XconfServer, groupName string, contextMap map[string]string, getGroupsData bool, getPrefixData bool, prefixList []string, fields log.Fields) []string

func AddLogUploaderContext

func AddLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap map[string]string, usePartnerAppType bool, vargs ...log.Fields) error

AddLogUploaderContext ..

func CalculateHashForContextData

func CalculateHashForContextData(data ContextData) (string, error)

func CleanupLusUploadRepository

func CleanupLusUploadRepository(settings *logupload.Settings, apiVersion string)

func CompareHashWithXDAS

func CompareHashWithXDAS(contextMap map[string]string, xdasHash string, tags []string) (bool, error)

func CreateAccountIdFeature

func CreateAccountIdFeature(accountId string) rfc.Feature

func CreatePartnerIdFeature

func CreatePartnerIdFeature(partnerId string) rfc.Feature

func DoSplunkLog

func DoSplunkLog(contextMap map[string]string, evaluationResult *estbfirmware.EvaluationResult, fields log.Fields)

func GetApplicationTypeFromPartnerId

func GetApplicationTypeFromPartnerId(id string) string

func GetCheckMinFirmwareHandler

func GetCheckMinFirmwareHandler(w http.ResponseWriter, r *http.Request)

func GetClientCertExpiryHeaderValue

func GetClientCertExpiryHeaderValue(r *http.Request) string

func GetClientProtocolHeaderValue

func GetClientProtocolHeaderValue(r *http.Request) string

func GetContextMapAndSettingTypes

func GetContextMapAndSettingTypes(r *http.Request) (map[string]string, []string)

func GetEstbChangelogsPath

func GetEstbChangelogsPath(w http.ResponseWriter, r *http.Request)

func GetEstbFirmwareSwuBseHandler

func GetEstbFirmwareSwuBseHandler(w http.ResponseWriter, r *http.Request)

func GetEstbFirmwareSwuHandler

func GetEstbFirmwareSwuHandler(w http.ResponseWriter, r *http.Request)

func GetEstbFirmwareVersionInfoPath

func GetEstbFirmwareVersionInfoPath(w http.ResponseWriter, r *http.Request)

func GetEstbLastlogPath

func GetEstbLastlogPath(w http.ResponseWriter, r *http.Request)

func GetExplanation

func GetExplanation(contextMap map[string]string, evaluationResult *estbfirmware.EvaluationResult) string

func GetFeatureControlSettingsHandler

func GetFeatureControlSettingsHandler(w http.ResponseWriter, r *http.Request)

func GetFirstElementsInContextMap

func GetFirstElementsInContextMap(contextMap map[string]string)

func GetInfoRefreshAllHandler

func GetInfoRefreshAllHandler(w http.ResponseWriter, r *http.Request)

func GetInfoRefreshHandler

func GetInfoRefreshHandler(w http.ResponseWriter, r *http.Request)

func GetInfoStatistics

func GetInfoStatistics(w http.ResponseWriter, r *http.Request)

func GetLogUploaderSettings

func GetLogUploaderSettings(w http.ResponseWriter, r *http.Request, isTelemetry2Settings bool)

func GetLogUploaderSettingsHandler

func GetLogUploaderSettingsHandler(w http.ResponseWriter, r *http.Request)

func GetLogUploaderT2SettingsHandler

func GetLogUploaderT2SettingsHandler(w http.ResponseWriter, r *http.Request)

func GetLogUploaderTelemetryProfilesHandler

func GetLogUploaderTelemetryProfilesHandler(w http.ResponseWriter, r *http.Request)

func GetMissingAndEmptyQueryParams

func GetMissingAndEmptyQueryParams(contextMap map[string]string, missingFields *[]string, emptyFields *[]string)

func GetPartnerFromAccountServiceByHostMac

func GetPartnerFromAccountServiceByHostMac(ws *xhttp.XconfServer, macAddress string, satToken string, vargs ...log.Fields) string

func GetTimeInLocalTimezone

func GetTimeInLocalTimezone(currentTime time.Time, contextMap map[string]string)

func GetTimezoneOffset

func GetTimezoneOffset() string

func IsAdditionalProperty

func IsAdditionalProperty(key string) bool

func IsAllowedRequest

func IsAllowedRequest(contextMap map[string]string, clientProtocolHeader string) bool

func IsCustomField

func IsCustomField(key string) bool

func IsMacPresentAndValid

func IsMacPresentAndValid(queryParams url.Values) (bool, string, string)

func IsSecureConnection

func IsSecureConnection(clientProtocolHeader string) bool

func LoadGroupServiceFeatureTags

func LoadGroupServiceFeatureTags(key cache.Key) (cache.Value, error)

func LogPreDisplayCleanup

func LogPreDisplayCleanup(lastConfigLog *coreef.ConfigChangeLog)

func LogResponse

func LogResponse(contextMap map[string]string, convertedContext *coreef.ConvertedContext, explanation string, evaluationResult *estbfirmware.EvaluationResult, fields log.Fields)

func LogResultSettings

func LogResultSettings(settings *logupload.Settings, telemetryRule *logupload.TelemetryRule, settingRules []*logupload.SettingRule, fields log.Fields)

func NormalizeCommonContext

func NormalizeCommonContext(contextMap map[string]string, estbMacKey string, ecmMacKey string)

func NormalizeEstbFirmwareContext

func NormalizeEstbFirmwareContext(ws *xhttp.XconfServer, r *http.Request, contextMap map[string]string, usePartnerAppType bool, shouldAddIp bool, fields log.Fields)

func NormalizeFeatureControlContext

func NormalizeFeatureControlContext(ws *xhttp.XconfServer, r *http.Request, contextMap map[string]string, fields log.Fields)

func NormalizeLogUploaderContext

func NormalizeLogUploaderContext(ws *xhttp.XconfServer, r *http.Request, contextMap map[string]string, usePartnerAppType bool, fields log.Fields)

func NullifyUnwantedFields

func NullifyUnwantedFields(permanentTelemetryProfile *logupload.PermanentTelemetryProfile)

func PathNotFoundHandler

func PathNotFoundHandler() http.Handler

PathNotFoundHandler - invalid URL should return 404 with message

func PostProcessFeatureControl

func PostProcessFeatureControl(ws *xhttp.XconfServer, contextMap map[string]string, isSecuredConnection bool, podData *PodData) []rfc.FeatureResponse

PostProcessFeatureControl

func RegisterTables

func RegisterTables()

func RemovePrefix

func RemovePrefix(key string, prefixSet []string) (string, bool)

func RouteDiagnosticApis

func RouteDiagnosticApis(r *mux.Router, s *xhttp.XconfServer)

Potential Todo: Add metrics to these routes as well

func RouteXconfDataserviceApis

func RouteXconfDataserviceApis(r *mux.Router, s *xhttp.XconfServer)

func ToTelemetry2Profile

func ToTelemetry2Profile(telemetryProfile []logupload.TelemetryElement) []logupload.TelemetryElement

func UpdatePenetrationMetrics

func UpdatePenetrationMetrics(context map[string]string, AccountServiceData *AccountServiceData, taglist []string, rfcPostProc string, fields log.Fields)

func WebServerInjection

func WebServerInjection(ws *xhttp.XconfServer, xc *XconfConfigs)

WebServerInjection - dependency injection

func XconfSetup

func XconfSetup(server *xhttp.XconfServer, r *mux.Router)

Xconf setup

Types

type AccountServiceData

type AccountServiceData struct {
	AccountId string
	TimeZone  string
	PartnerId string
}

func AddFeatureControlContextFromAccountService

func AddFeatureControlContextFromAccountService(ws *xhttp.XconfServer, contextMap map[string]string, satToken string, vargs ...log.Fields) *AccountServiceData

type AuxiliaryFirmware

type AuxiliaryFirmware struct {
	Prefix    string
	Extension string
}

type ContextData

type ContextData struct {
	Mac     string `json:"mac"`
	Model   string `json:"model"`
	Partner string `json:"partner"`
	//FirmwareVersion string   `json:"firmwareVersion"`
	SerialNum  string   `json:"serialNum"`
	Experience string   `json:"experience"`
	AccountId  string   `json:"accountId"`
	Tags       []string `json:"tags"` // tags from tagging service and xdas ft
}

func NewContextDataFromContextMap

func NewContextDataFromContextMap(contextMap map[string]string, tags []string) ContextData

type PodData

type PodData struct {
	AccountId string
	TimeZone  string
	PartnerId string
}

type PrecookData

type PrecookData struct {
	AccountId                   string
	PartnerId                   string
	Model                       string
	ApplicationType             string
	Env                         string
	FwVersion                   string
	EstbIp                      string
	Experience                  string
	RfcHash                     string
	RfcRulesEngineHash          string
	RfcPostProcessingHash       string
	CtxHash                     string
	OfferedFwVersion            string
	OfferedFwRfcHash            string
	OfferedFwRfcRulesEngineHash string
}

type TelemetryEvaluationResult

type TelemetryEvaluationResult struct {
	RulesMatched bool
	ProfilesData []util.Dict
}

func GetTelemetryTwoProfileResponeDicts

func GetTelemetryTwoProfileResponeDicts(contextMap map[string]string, fields log.Fields) (*TelemetryEvaluationResult, error)

type XconfConfigs

type XconfConfigs struct {
	DeriveAppTypeFromPartnerId   bool
	PartnerApplicationTypes      []string // List of partner's application type
	EnableDeviceService          bool
	EnableDeviceDBLookup         bool
	EnableMacAccountServiceCall  bool
	AccountServiceMacPrefix      string
	EnableAccountService         bool
	EnableTaggingService         bool
	EnableTaggingServiceRFC      bool
	IPv4NetworkMaskPrefixLength  int32
	IPv6NetworkMaskPrefixLength  int32
	EnableFwDownloadLogs         bool
	EnableRfcPrecook             bool
	EnableRfcPrecookForOfferedFw bool
	EnableRfcPrecook304          bool
	RfcPrecookStartTime          string
	RfcPrecookEndTime            string
	RfcPrecookTimeZone           *time.Location
	RfcPrecookTimeFormat         string
	EnableGroupService           bool
	EnableFtGroups               bool
	EnableFtMacTags              bool
	EnableFtAccountTags          bool
	EnableFtPartnerTags          bool
	GroupServiceModelSet         util.Set
	MacTagsModelSet              util.Set
	AccountTagsModelSet          util.Set
	PartnerTagsModelSet          util.Set
	MacTagsPrefixList            []string
	AccountTagsPrefixList        []string
	PartnerTagsPrefixList        []string
	ReturnAccountId              bool
	ReturnAccountHash            bool
	EstbRecoveryFirmwareVersions string
	DiagnosticAPIsEnabled        bool
	Account_mgmt                 string
	GroupServiceCacheEnabled     bool
	RfcReturnCountryCode         bool
	RfcCountryCodeModelsSet      util.Set
	RfcCountryCodePartnersSet    util.Set
	AuxiliaryFirmwareList        []AuxiliaryFirmware
	PartnerIdValidationEnabled   bool
	ValidPartnerIdRegex          *regexp.Regexp
}
var (
	Ws *xhttp.XconfServer
	Xc *XconfConfigs
)

Ws - webserver object

func GetXconfConfigs

func GetXconfConfigs(conf *conf.Config) *XconfConfigs

Directories

Path Synopsis
dcm
*
*
*
*
*

Jump to

Keyboard shortcuts

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