arcep

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package arcep holds the connector of the national numbering plan the Autorité de régulation des communications électroniques, des postes et de la distribution de la presse publishes under the Licence Ouverte (docs/sources.md): the ranges of phone numbers it has assigned (MAJNUM), joined with the name and SIREN of the operator each range is assigned to (identifiants_CE). The files are Windows-1252 ("ANSI") and replaced whole after each update.

Each snapshot row is one assigned range. Plan indexes them into the domain.NumberingPlan phone numbers are looked up in. An assignment says which operator holds a number's range, nothing about who uses the number.

Index

Constants

View Source
const (
	// ColumnPrefix is the range's prefix ("EZABPQM").
	ColumnPrefix = "prefix"
	// ColumnFirst and ColumnLast are the first and last numbers of the
	// range, in national form, of the same number of digits.
	ColumnFirst = "first"
	ColumnLast  = "last"
	// ColumnOperator is the code of the operator holding the range.
	ColumnOperator = "operator"
	// ColumnOperatorName and ColumnOperatorSIREN are the operator's name
	// and SIREN, "" when the operators file does not give them.
	ColumnOperatorName  = "operator_name"
	ColumnOperatorSIREN = "operator_siren"
	// ColumnTerritory is where the range is used.
	ColumnTerritory = "territory"
	// ColumnAssignedOn is the assignment date, AAAA-MM-JJ.
	ColumnAssignedOn = "assigned_on"
)

Columns of a numbering snapshot row.

View Source
const NumberingSource = signal.NumberingSource

NumberingSource is the name of the numbering plan, as shown to users.

View Source
const NumberingURL = "https://extranet.arcep.fr/uploads/MAJNUM.csv"

NumberingURL is the file of the assigned numbering ranges (MAJNUM).

View Source
const OperatorsURL = "https://extranet.arcep.fr/uploads/identifiants_CE.csv"

OperatorsURL is the file of the operators ARCEP identifies, with the code ("mnémonique") the numbering file names them by.

Variables

View Source
var ErrFormat = errors.New("unexpected ARCEP file format")

ErrFormat means a file is not laid out as docs/sources.md records it.

Functions

func Hosts

func Hosts() []string

Hosts returns the hosts a Fetcher reaches, for the HTTP client allowlist.

func NumberingInfo added in v0.37.0

func NumberingInfo() domain.SourceInfo

NumberingInfo describes the ARCEP numbering plan for GET /v1/sources: the Licence Ouverte 1.0 (fr-lo) of its data.gouv.fr dataset, checked on 02/11/2026.

func ParseNumbering

func ParseNumbering(r io.Reader, operators map[string]Operator) (domain.Snapshot, error)

ParseNumbering reads the published numbering file into a snapshot, one row per assigned range, with the name and SIREN of its holder from operators. A holder missing from operators, which ARCEP updates on another schedule, is kept with its code only. A file that departs from the recorded format, or whose ranges overlap, is rejected with ErrFormat rather than half read.

func ParseOperators

func ParseOperators(r io.Reader) (map[string]Operator, error)

ParseOperators reads the published operators file into a map from code to operator. Only the name and the SIREN are kept: the address is not needed. A file that departs from the recorded format is rejected with ErrFormat rather than half read.

func Plan added in v0.28.0

func Plan(snap domain.Snapshot) (*domain.NumberingPlan, error)

Plan indexes the ranges of a numbering snapshot. It rejects with ErrFormat a snapshot whose rows do not read as ranges or whose ranges overlap: a number would then have two holders.

Types

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

Fetcher downloads the numbering and operators files and joins them into a numbering snapshot. It implements app.SourceFetcher.

func NewNumbering

func NewNumbering(client Getter, numberingURL, operatorsURL string) *Fetcher

NewNumbering returns the Fetcher of the numbering plan, which downloads the files at numberingURL and operatorsURL, NumberingURL and OperatorsURL in production, through client.

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context) (domain.Snapshot, error)

Fetch downloads and parses the operators file, then the numbering file.

func (*Fetcher) Spec

func (f *Fetcher) Spec() domain.SnapshotSpec

Spec declares the snapshot columns and the least number of rows.

type Getter

type Getter interface {
	Get(ctx context.Context, rawURL string) ([]byte, error)
}

Getter fetches a URL; *httpclient.Client is one.

type Operator

type Operator struct {
	// Name is the operator's name, as ARCEP lists it.
	Name string
	// SIREN is the operator's SIREN, "" for a foreign operator or a number
	// that fails its check digit.
	SIREN string
}

Operator is a holder of numbering resources.

Jump to

Keyboard shortcuts

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