Module ocs

This library module implements the public API for the ocs application.

Copyright © 2016 - 2026 SigScale Global Inc.

Description

This library module implements the public API for the ocs application.

Data Types

aka_cred()

aka_cred() = #aka_cred{k = binary(), opc = binary(), dif = integer()}

bucket_attributes()

bucket_attributes() = #{bucket_type := normal | session, from_bucket => [bucket_source()], reservations => reservations()}

bucket_source()

bucket_source() = #{id := string(), amount := pos_integer(), unit_size := pos_integer(), unit_price := pos_integer(), expire := pos_integer() | undefined}

bucket_status()

bucket_status() = active | expired | suspended

eap_method()

eap_method() = pwd | ttls | aka | akap

match()

match() = {exact, term()} | {notexact, term()} | {lt, term()} | {lte, term()} | {gt, term()} | {gte, term()} | {like, [term()]}

offer_status()

offer_status() = in_study | in_design | in_test | active | rejected | launched | retired | obsolete

password()

password() = [50..57 | 97..104 | 106..107 | 109..110 | 112..116 | 119..122]

pla_ref()

pla_ref() = #pla_ref{id = string() | undefined | '_', href = string() | undefined | '_', name = string() | undefined | '_', class_type = string() | undefined | '_', base_type = string() | undefined | '_', schema = string() | undefined | '_', ref_type = string() | undefined | '_'}

product_price_type()

product_price_type() = recurring | one_time | usage | tariff | pla_ref()

product_status()

product_status() = created | pending_active | aborted | cancelled | active | suspended | pending_terminate | terminated

quantity()

quantity() = #quantity{amount = integer(), units = atom() | string()}

range()

range() = #range{lower = quantity(), upper = quantity()}

rate()

rate() = #rate{numerator = quantity(), denominator = quantity()}

recur_period()

recur_period() = hourly | daily | weekly | monthly | yearly

reservation()

reservation() = #{ts := pos_integer(), debit := non_neg_integer(), reserve := non_neg_integer(), service_id => non_neg_integer(), charging_key => non_neg_integer()}

reservations()

reservations() = #{SesssionID::list() => reservation()}

resource()

resource() = #resource{id = string() | undefined | '$1' | '_', href = string() | undefined | '_', name = string() | undefined | '_' | '$2', description = string() | undefined | '_', category = string() | undefined | '_', class_type = string() | undefined | '_', base_type = string() | undefined | '_', schema = string() | undefined | '_', state = string() | undefined | '_', substate = string() | undefined | '_', version = string() | undefined | '_', start_date = pos_integer() | undefined | '_', end_date = pos_integer() | undefined | '_', last_modified = {TS::pos_integer(), N::pos_integer()} | undefined | '_', related = [resource_rel()] | '_', specification = specification_ref() | undefined | '_', characteristic = [resource_char()] | '_'}

resource_char()

resource_char() = #resource_char{name = string() | undefined | '_', class_type = string() | undefined | '_', schema = string() | undefined | '_', value = term() | undefined | '_'}

resource_rel()

resource_rel() = #resource_rel{id = string() | undefined | '_', href = string() | undefined | '_', name = string() | undefined | '$4' | '_', type = string() | undefined | '_', referred_type = string() | undefined | '_'}

service_status()

service_status() = feasibilityChecked | designed | reserved | active | inactive | terminated

specification_ref()

specification_ref() = #specification_ref{id = string() | undefined | '_' | '$3', href = string() | undefined | '_', name = string() | undefined | '_', version = string() | undefined | '_'}

Function Index

add_client/2Create an entry in the client table.
add_client/3Equivalent to add_client(Address, 3799, radius, Secret, PasswordRequired).
add_client/5Equivalent to add_client(Address, Port, Protocol, Secret, PasswordRequired, true).
add_client/6Create an entry in the client table.
find_client/1Find a client by IP address.
update_client/2Update a client password.
update_client/3Update client port and protocol.
get_clients/0Get all clients.
delete_client/1Delete an entry from the client table.
get_products/0
query_product/4Query product.
add_product/2Equivalent to add_product(Offer, ServiceRefs, undefined, undefined, []).
add_product/3Equivalent to add_product(Offer, ServiceRefs, undefined, undefined, Characteristics).
add_product/5Add a product inventory subscription instance.
update_product/1Update an existing Product.
find_product/1Look up entry in product table.
delete_product/1Delete an entry from product table.
add_service/2Equivalent to add_service(Identity, Password, undefined, [], true, false).
add_service/3Equivalent to add_service(Identity, Password, ProductRef, [], true, false).
add_service/4Equivalent to add_service(Identity, Password, ProductRef, Chars, [], true, false).
add_service/5Equivalent to add_service(Identity, Password, ProductRef, Chars, Attributes, true, false).
add_service/8Create an entry in the service table.
update_service/1Update an existing Service.
add_bucket/2Add a new bucket to bucket table or update exsiting bucket.
find_bucket/1Look up an entry in the bucket table.
get_buckets/0Get all buckets.
get_buckets/1Get all buckets for given product reference.
query_bucket/3Query bucket.
delete_bucket/1Delete entry in the bucket table.
adjustment/1Applying balance adjustment.
log_adjustment/7*Log an adjustment in the ABMF log.
find_service/1Look up an entry in the service table.
get_services/0Get all entries in the service table.
query_service/3Query services.
delete_service/1Delete an entry in the service table.
add_offer/1Add a new entry in offer table.
find_offer/1Find offer by product id.
get_offers/0Get all entries in the offer table.
delete_offer/1Delete an entry from the offer table.
query_offer/7Query offer entires.
add_resource/1Create a new Resource.
update_resource/1Update an existing Resource.
get_resources/0List all entries in the resource table.
get_resource/1Get a Resource by identifier.
delete_resource/1Delete a Resource.
query_resource/5Query resources.
generate_password/0Equivalent to generate_password(12).
generate_identity/0Equivalent to generate_identity(7).
start/4Equivalent to start(Type, Address, Port, []).
start/5Start a RADIUS/DIAMETER request handler.
stop/3Stop a RADIUS/DIAMETER request handler.
get_acct/1Get RADIUS/DIAMETER acct request handlers.
get_auth/1Get RADIUS/DIAMETER auth request handlers.
add_user/3Add an HTTP user.
list_users/0List HTTP users.
get_user/1Get an HTTP user record.
delete_user/1Delete an existing HTTP user.
query_users/3Query the user table.
statistics/1Get system statistics.
clean_services/1Clean the service table.
clean_buckets/0Clean the bucket table.
clean_buckets/1Clean the bucket table.
clean_reservations/1Clean reservations held in balance buckets.
clean_reservations/2Clean reservations held in balance buckets.
parse_bucket/1Replace reservations field of bucket with attributes.
subscription/4Apply one time and recurring charges.
charge/3*Charge Amount to Buckets.
credit/3*Credit Amount on Buckets.
end_period/2Calculate end of period.

Function Details

add_client/2

add_client(Address, Secret) -> Result

Equivalent to add_client(Address, 3799, radius, Secret, true).

Create an entry in the client table.

add_client/3

add_client(Address, Secret, PasswordRequired) -> Result

Equivalent to add_client(Address, 3799, radius, Secret, PasswordRequired).

add_client/5

add_client(Address, Port, Protocol, Secret, PasswordRequired) -> Result

Equivalent to add_client(Address, Port, Protocol, Secret, PasswordRequired, true).

add_client/6

add_client(Address, Port, Protocol, Secret, PasswordRequired, Trusted) -> Result

Create an entry in the client table.

find_client/1

find_client(Address) -> Result

Find a client by IP address.

update_client/2

update_client(Address, Password) -> Result

Update a client password.

update_client/3

update_client(Address, Port, Protocol) -> Result

Update client port and protocol.

get_clients/0

get_clients() -> Result

Get all clients.

delete_client/1

delete_client(Client) -> ok

Delete an entry from the client table.

get_products/0

get_products() -> any()

query_product/4

query_product(Cont, MatchId, MatchOffer, MatchService) -> Result

Query product

add_product/2

add_product(Offer, ServiceRefs) -> Result

Equivalent to add_product(Offer, ServiceRefs, undefined, undefined, []).

add_product/3

add_product(Offer, ServiceRefs, Characteristics) -> Result

Equivalent to add_product(Offer, ServiceRefs, undefined, undefined, Characteristics).

add_product/5

add_product(OfferId, ServiceRefs, StartDate, EndDate, Characteristics) -> Result

Add a product inventory subscription instance.

update_product/1

update_product(Product) -> Result

Update an existing Product.

find_product/1

find_product(ProductRef) -> Result

Look up entry in product table

delete_product/1

delete_product(ProductRef) -> Result

Delete an entry from product table

add_service/2

add_service(Identity, Password) -> Result

Equivalent to add_service(Identity, Password, undefined, [], true, false).

add_service/3

add_service(Identity, Password, ProductRef) -> Result

Equivalent to add_service(Identity, Password, ProductRef, [], true, false).

add_service/4

add_service(Identity, Password, ProductRef, Chars) -> Result

Equivalent to add_service(Identity, Password, ProductRef, Chars, [], true, false).

add_service/5

add_service(Identity, Password, ProductRef, Chars, Attributes) -> Result

Equivalent to add_service(Identity, Password, ProductRef, Chars, Attributes, true, false).

add_service/8

add_service(Identity, Password, State, ProductRef, Chars, Attributes, EnabledStatus, MultiSessions) -> Result

Create an entry in the service table.

Authentication will be done using Password. An optional list of RADIUS Attributes, to be returned in an AccessRequest response, may be provided. These attributes will overide any default values.

ProductRef key for product inventory reference, Enabled status and MultiSessions status may be provided.

update_service/1

update_service(Service) -> Result

Update an existing Service.

add_bucket/2

add_bucket(ProductRef, Bucket) -> Result

Add a new bucket to bucket table or update exsiting bucket

find_bucket/1

find_bucket(BucketId) -> Result

Look up an entry in the bucket table.

get_buckets/0

get_buckets() -> Result

Get all buckets.

get_buckets/1

get_buckets(ProdRef) -> Result

Get all buckets for given product reference.

query_bucket/3

query_bucket(Cont, MatchId, MatchProduct) -> Result

Query bucket

delete_bucket/1

delete_bucket(BucketId) -> ok

Delete entry in the bucket table.

adjustment/1

adjustment(Adjustment) -> Result

Applying balance adjustment.

log_adjustment/7 *

log_adjustment(AmountAfter, DeleteRefs, BucketRefs, Units, ProductRef, Amount, AmountBefore) -> Result

Log an adjustment in the ABMF log.

find_service/1

find_service(Identity) -> Result

Look up an entry in the service table.

get_services/0

get_services() -> Result

Get all entries in the service table.

query_service/3

query_service(Cont, MatchId, MatchProduct) -> Result

Query services

delete_service/1

delete_service(Identity) -> ok

Delete an entry in the service table.

add_offer/1

add_offer(Offer) -> Result

Add a new entry in offer table.

find_offer/1

find_offer(OfferID) -> Result

Find offer by product id

get_offers/0

get_offers() -> Result

Get all entries in the offer table.

delete_offer/1

delete_offer(OfferID) -> Result

Delete an entry from the offer table.

query_offer/7

query_offer(Cont, Name, Description, Status, SDT, EDT, Price) -> Result

Query offer entires

add_resource/1

add_resource(Resource) -> Result

Create a new Resource.

update_resource/1

update_resource(Resource) -> Result

Update an existing Resource.

get_resources/0

get_resources() -> Result

List all entries in the resource table.

get_resource/1

get_resource(ResourceID) -> Result

Get a Resource by identifier.

delete_resource/1

delete_resource(ResourceID) -> Result

Delete a Resource.

query_resource/5

query_resource(Cont, MatchId, MatchName, MatchResSpecId, MatchRelName) -> Result

Query resources

generate_password/0

generate_password() -> password()

Equivalent to generate_password(12).

generate_identity/0

generate_identity() -> string()

Equivalent to generate_identity(7).

start/4

start(Protocol, Type, Address, Port) -> Result

Equivalent to start(Type, Address, Port, []).

start/5

start(Protocol, Type, Address, Port, Options) -> Result

Start a RADIUS/DIAMETER request handler.

stop/3

stop(Protocol, Type, Pid) -> Result

Stop a RADIUS/DIAMETER request handler.

get_acct/1

get_acct(Protocol) -> Result

Get RADIUS/DIAMETER acct request handlers.

get_auth/1

get_auth(Protocol) -> Result

Get RADIUS/DIAMETER auth request handlers.

add_user/3

add_user(Username, Password, UserData) -> Result

Add an HTTP user. HTTP Basic authentication (RFC7617) is required with Username and Password used to construct the Authorization header in requests.

UserData contains addtional properties specific to each user.

list_users/0

list_users() -> Result

Equivalent to mod_auth:list_users(Address, Port, Dir).

List HTTP users.

get_user/1

get_user(Username) -> Result

Equivalent to mod_auth:get_user(Username, Address, Port, Dir).

Get an HTTP user record.

delete_user/1

delete_user(Username) -> Result

Delete an existing HTTP user.

query_users/3

query_users(Cont, MatchId, MatchLocale) -> Result

Query the user table.

statistics/1

statistics(Item) -> Result

Get system statistics.

clean_services/1

clean_services(Before) -> Result

Clean the service table.

Traverse the service table, removing expired sessions.

The service table entries include a session_attributes field used to track active sessions. It is a list of {TS, Attributes} where TS is a timestamp and Attributes is a list of RADIUS or DIAMETER AVPs uniquely identifying a session. Instability of the RADIUS/DIAMETER connections may result in sessions not being removed.

This function lazily traverses the service table, removing any session timestamped earlier than Before.

clean_buckets/0

clean_buckets() -> Result

Clean the bucket table.

Traverse the buckets table, removing expired buckets.

The bucket table entries optionally include an expiration date and time in the end_date field.

This function lazily traverses the bucket table, removing expired buckets.

clean_buckets/1

clean_buckets(Before) -> Result

Clean the bucket table.

Traverse the buckets table, removing old buckets.

WARNING: This will permanently delete subscriber balances!

There should be no reason to use this function in normal operation of the OCS. Expired buckets are removed as they are encountered during normal rating operations.

The bucket table entries include a last_modified field with a timestamp of the last write. The end_date field may (optionally) contain an expiration date.

This function lazily traverses the bucket table, removing expired buckets and stale buckets which have not been modified after Before.

clean_reservations/1

clean_reservations(Before) -> Result

Equivalent to clean_reservations(Before, true).

Clean reservations held in balance buckets.

clean_reservations/2

clean_reservations(Before, Refund) -> Result

Clean reservations held in balance buckets.

Traverse the buckets table, removing old reservations.

The bucket table entries include a reservations attribute describing credit debits and reserves and a timestamp of the last transaction.

This function lazily traverses the bucket table, removing reservations which haven't been updated since Before.

If Refund is true the unused portion of reservations to be removed will be returned to the remaining amount of the bucket.

parse_bucket/1

parse_bucket(Bucket) -> Bucket

Replace reservations field of bucket with attributes.

subscription/4

subscription(Product, Offer, Buckets, InitialFlag) -> Result

Apply one time and recurring charges.

charge/3 *

charge(ProdRef, Amount, Buckets) -> Buckets

Charge Amount to Buckets.

credit/3 *

credit(Units, Amount, Buckets) -> Result

Credit Amount on Buckets.

end_period/2

end_period(StartTime, Period) -> EndTime

Calculate end of period.


Generated by EDoc