diff --git a/code/API_definitions/connected-network-type.yaml b/code/API_definitions/connected-network-type.yaml new file mode 100644 index 00000000..ea1758b5 --- /dev/null +++ b/code/API_definitions/connected-network-type.yaml @@ -0,0 +1,420 @@ +openapi: 3.0.3 +info: + title: Connected Network Type + description: | + This API provides the customer with the ability to query to which Mobile Communication Technology it is connected to. + + # Introduction + + ## Connected Network Type + + The API consumer is able to query the device's connected network type. The API provider can determine this in various ways. For example, the network type can be inferred from the specific radio cell to which the device is connected, as radio cells only support a single technology. It is important to note that the API does not query the device directly. + + # Relevant terms and definitions + + * **Device**: A device refers to any physical entity that can connect to a network and participate in network communication. + At least one identifier for the device (user equipment) out of four options: IPv4 address, IPv6 address, Phone number, or Network Access Identifier assigned by the mobile network operator for the device. + + * **Network Type** : Network Type is intended to provide insight into connected network's capabilities from standards perspective, and to reflect the mobile technology that would be displayed by the device to the end user where applicable. Actual network capabilities may differ based on implementation and MUST be checked with the connected network provider. + - `2G`, if device is connected to the 2G network technology (alternative indicators such as "G" or "E" may be displayed on the device) + - `3G`, if device is connected to the 3G network technology (alternative indicators such as "H" or "H+" may be displayed on the device) + - `4G`, if device is connected to the 4G network technology (alternative indicators such as "LTE" or "LTE+" may be displayed on the device) + - `5G`, if device is connected to the 5G network technology + - `UNKNOWN` if connection [technology] can not be determined + + + * **LastStatusTime** : This property specifies the time when the status was last updated. Its presence in the response indicates the freshness of the information, while its absence implies the information may be outdated or its freshness is uncertain. + + # API Functionality + + The API exposes following capabilities: + + ## Connected Network Type + + The endpoint `POST /retrieve` allows to get connected Network Type. + + # Identifying the device from the access token + + This API requires the API consumer to identify a device as the subject of the API as follows: + - When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided. + + - When a three-legged access token is used however, this optional identifier MUST NOT be provided, as the subject will be uniquely identified from the access token. + + This approach simplifies API usage for API consumers using a three-legged access token to invoke the API by relying on the information that is associated with the access token and was identified during the authentication process. + + ## Error handling: + - If the subject cannot be identified from the access token and the optional `device` object is not included in the request, then the server will return an error with the `422 MISSING_IDENTIFIER` error code. + + - If the subject can be identified from the access token and the optional `device` object is also included in the request, then the server will return an error with the `422 UNNECESSARY_IDENTIFIER` error code. This will be the case even if the same device is identified by these two methods, as the server is unable to make this comparison. + ## Further info and support + + (FAQs will be added in a later version of the documentation) + + termsOfService: http://swagger.io/terms/ + contact: + email: project-email@sample.com + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + version: wip +externalDocs: + description: Product documentation at CAMARA + url: https://github.com/camaraproject/ + +servers: + - url: "{apiRoot}/connected-network-type/vwip" + variables: + apiRoot: + default: http://localhost:9091 + description: API root +tags: + - name: Connected Network Type + description: Operations to get the network type device is connected to +paths: + /retrieve: + post: + tags: + - Connected Network Type + summary: "Get the connected network type" + description: Get the connected network type to which the user device is connected + operationId: getConnectedNetworkType + parameters: + - $ref: '#/components/parameters/x-correlator' + security: + - openId: + - connected-network-type:read + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ConnectedNetworkTypeRequest" + required: true + responses: + "200": + description: Contains connected network type + headers: + x-correlator: + $ref: '#/components/headers/x-correlator' + content: + application/json: + schema: + $ref: "#/components/schemas/ConnectedNetworkTypeResponse" + examples: + Connected-to-4G: + value: + lastStatusTime: "2024-02-20T10:41:38.657Z" + connectedNetworkType: 4G + Connected-to-5G: + value: + lastStatusTime: "2024-02-20T10:41:38.657Z" + connectedNetworkType: 5G + Connected-to-Undetermined: + value: + lastStatusTime: "2024-02-20T10:41:38.657Z" + connectedNetworkType: UNKNOWN + "400": + $ref: "#/components/responses/Generic400" + "401": + $ref: "#/components/responses/Generic401" + "403": + $ref: "#/components/responses/ConnectedNetworkTypePermissionDenied403" + "404": + $ref: "#/components/responses/ConnectedStatusNotFound404" + "422": + $ref: "#/components/responses/ConnectedStatusUnprocessableEntity422" + "500": + $ref: "#/components/responses/Generic500" + "503": + $ref: "#/components/responses/Generic503" +components: + securitySchemes: + openId: + type: openIdConnect + openIdConnectUrl: https://example.com/.well-known/openid-configuration + parameters: + x-correlator: + name: x-correlator + in: header + description: Correlation id for the different services + schema: + type: string + headers: + x-correlator: + description: Correlation id for the different services + schema: + type: string + schemas: + LastStatusTime: + description: Last time that the associated connected Network Type was updated + type: string + format: date-time + example: "2024-02-20T10:41:38.657Z" + + ConnectedNetworkTypeResponse: + type: object + required: + - connectedNetworkType + properties: + lastStatusTime: + $ref: "#/components/schemas/LastStatusTime" + connectedNetworkType: + $ref: "#/components/schemas/ConnectedNetworkType" + + ConnectedNetworkType: + description: | + * UNKNOWN: Used when connection [technology] can not be determined + * 2G: 2nd Generation Mobile Communication Technology + * 3G: 3rd Generation Mobile Communication Technology + * 4G: 4th Generation Mobile Communication Technology + * 5G: 5th Generation Mobile Communication Technology + + type: string + enum: + - 2G + - 3G + - 4G + - 5G + - UNKNOWN + + Device: + description: | + End-user equipment able to connect to a mobile network. Examples of devices include smartphones or IoT sensors/actuators. + + The developer can choose to provide the below specified device identifiers: + + * `ipv4Address` + * `ipv6Address` + * `phoneNumber` + * `networkAccessIdentifier` + + NOTE: the MNO might support only a subset of these options. The API invoker can provide multiple identifiers to be compatible across different MNOs. In this case the identifiers MUST belong to the same device. + type: object + properties: + phoneNumber: + $ref: "#/components/schemas/PhoneNumber" + networkAccessIdentifier: + $ref: "#/components/schemas/NetworkAccessIdentifier" + ipv4Address: + $ref: "#/components/schemas/DeviceIpv4Addr" + ipv6Address: + $ref: "#/components/schemas/DeviceIpv6Address" + minProperties: 1 + + PhoneNumber: + description: A public identifier addressing a telephone subscription. In mobile networks it corresponds to the MSISDN (Mobile Station International Subscriber Directory Number). In order to be globally unique it has to be formatted in international format, according to E.164 standard, prefixed with '+'. + type: string + pattern: '^\+[1-9][0-9]{4,14}$' + example: "+123456789" + + NetworkAccessIdentifier: + description: A public identifier addressing a subscription in a mobile network. In 3GPP terminology, it corresponds to the GPSI formatted with the External Identifier ({Local Identifier}@{Domain Identifier}). Unlike the telephone number, the network access identifier is not subjected to portability ruling in force, and is individually managed by each operator. + type: string + example: "123456789@domain.com" + + DeviceIpv4Addr: + type: object + description: | + The device should be identified by either the public (observed) IP address and port as seen by the application server, or the private (local) and any public (observed) IP addresses in use by the device (this information can be obtained by various means, for example from some DNS servers). + + If the allocated and observed IP addresses are the same (i.e. NAT is not in use) then the same address should be specified for both publicAddress and privateAddress. + + If NAT64 is in use, the device should be identified by its publicAddress and publicPort, or separately by its allocated IPv6 address (field ipv6Address of the Device object) + + In all cases, publicAddress must be specified, along with at least one of either privateAddress or publicPort, dependent upon which is known. In general, mobile devices cannot be identified by their public IPv4 address alone. + properties: + publicAddress: + $ref: "#/components/schemas/SingleIpv4Addr" + privateAddress: + $ref: "#/components/schemas/SingleIpv4Addr" + publicPort: + $ref: "#/components/schemas/Port" + anyOf: + - required: [publicAddress, privateAddress] + - required: [publicAddress, publicPort] + example: + publicAddress: "84.125.93.10" + publicPort: 59765 + + SingleIpv4Addr: + description: A single IPv4 address with no subnet mask + type: string + format: ipv4 + example: "84.125.93.10" + + Port: + description: TCP or UDP port number + type: integer + minimum: 0 + maximum: 65535 + + DeviceIpv6Address: + description: | + The device should be identified by the observed IPv6 address, or by any single IPv6 address from within the subnet allocated to the device (e.g. adding ::0 to the /64 prefix). + type: string + format: ipv6 + example: 2001:db8:85a3:8d3:1319:8a2e:370:7344 + + ConnectedNetworkTypeRequest: + type: object + properties: + device: + $ref: "#/components/schemas/Device" + + ErrorInfo: + type: object + required: + - status + - code + - message + properties: + status: + type: integer + description: HTTP response status code + code: + type: string + description: Code given to this error + message: + type: string + description: Detailed error description + + responses: + Generic400: + description: Problem with the client request + headers: + x-correlator: + $ref: '#/components/headers/x-correlator' + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorInfo" + example: + status: 400 + code: "INVALID_ARGUMENT" + message: "Client specified an invalid argument, request body or query param" + Generic401: + description: Authentication problem with the client request + headers: + x-correlator: + $ref: '#/components/headers/x-correlator' + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorInfo" + example: + status: 401 + code: "UNAUTHENTICATED" + message: "Request not authenticated due to missing, invalid, or expired credentials" + ConnectedNetworkTypePermissionDenied403: + description: | + Client does not have sufficient permission. + In addition to regular scenario of `PERMISSION_DENIED`, other scenarios may exist: + - Phone number cannot be deducted from access token context.(`{"code": "NUMBER_VERIFICATION.INVALID_TOKEN_CONTEXT","message": "Phone number cannot be deducted from access token context"}`) + headers: + X-Correlator: + description: Correlation id for the different services + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorInfo' + examples: + PermissionDenied: + value: + status: 403 + code: "PERMISSION_DENIED" + message: "Client does not have sufficient permissions to perform this action" + ConnectedStatusNotFound404: + description: Resource Not Found + headers: + x-correlator: + $ref: '#/components/headers/x-correlator' + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorInfo" + examples: + NotFound: + value: + status: 404 + code: NOT_FOUND + message: "The specified resource is not found" + DeviceIdentifierNotFound: + value: + status: 404 + code: IDENTIFIER_NOT_FOUND + message: Some identifier cannot be matched to a device + Generic409: + description: Conflict + headers: + x-correlator: + $ref: '#/components/headers/x-correlator' + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorInfo" + example: + status: 409 + code: CONFLICT + message: "The specified resource is in a conflict" + ConnectedStatusUnprocessableEntity422: + description: Unprocessable Entity + headers: + x-correlator: + $ref: '#/components/headers/x-correlator' + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorInfo" + examples: + UnsupportedDeviceIdentifiers: + value: + status: 422 + code: UNSUPPORTED_IDENTIFIER + message: "None of the provided device identifiers is supported by the implementation" + InconsistentDeviceIdentifiers: + value: + status: 422 + code: IDENTIFIER_MISMATCH + message: Device identifiers mismatch + DeviceNotSupported: + value: + status: 422 + code: SERVICE_NOT_APPLICABLE + message: Service not applicable to the device + UnnecessaryDeviceIdentifier: + value: + status: 422 + code: UNNECESSARY_IDENTIFIER + message: The device is already identified by the access token + MissingIdentifier: + value: + status: 422 + code: MISSING_IDENTIFIER + message: The device cannot be identified + Generic500: + description: Server error + headers: + x-correlator: + $ref: '#/components/headers/x-correlator' + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorInfo" + example: + status: 500 + code: "INTERNAL" + message: "Server error" + Generic503: + description: Service unavailable. Typically the server is down. + headers: + x-correlator: + $ref: '#/components/headers/x-correlator' + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorInfo" + example: + status: 503 + code: "UNAVAILABLE" + message: "Service unavailable"