Commit 17cc4190 authored by Ikram Haq's avatar Ikram Haq
Browse files

Add new Endpoint to Get the zone subscriptions

parent 84efc74c
Loading
Loading
Loading
Loading
+395 −49
Original line number Diff line number Diff line
@@ -1112,6 +1112,133 @@ paths:
                '204':
                  $ref: '#/components/responses/204'
      x-swagger-router-controller: 'subscriptions'
  /subscriptions/users/{subscriptionId}:
    get:
      tags:
        - 'location'
      summary: 'Retrieve subscription information'
      description: 'The GET method is used to retrieve information about this subscription. '
      operationId: userSubGET
      parameters:
        - $ref: '#/components/parameters/Path.SubscrId'
      responses:
        '200':
          description: 'Upon success, a response body containing data type describing the specific Location event subscription is returned.'
          content:
            application/json:
              schema:
                type: object
                required:
                  - UserLocationEventSubscription
                properties:
                  userLocationEventSubscription:
                    $ref: '#/components/schemas/UserLocationEventSubscription'
                  userLocationPeriodicSubscription:
                    $ref: '#/components/schemas/UserLocationPeriodicSubscription'
                example:
                  - userLocationEventSubscription:
                      subscriptionType: 'UserLocationEventSubscription'
                      callbackReference: 'http://my.callback.com/user-location-notification/some-id'
                      address: 'acr:10.0.0.1'
                      locationEventCriteria:
                        - ENTERING_AREA_EVENT
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
      x-swagger-router-controller: 'subscriptions'
    put:
      tags:
        - 'location'
      summary: 'Updates a subscription information'
      description: 'The PUT method is used to update the existing subscription.'
      operationId: userSubPUT
      requestBody:
        description: 'Subscription to be modified'
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                  userLocationEventSubscription:
                    $ref: '#/components/schemas/UserLocationEventSubscription'
                  userLocationPeriodicSubscription:
                    $ref: '#/components/schemas/UserLocationPeriodicSubscription'
              example:
                - userLocationEventSubscription:
                    subscriptionType: 'UserLocationEventSubscription'
                    callbackReference: 'http://my.callback.com/user-location-notification/some-id'
                    address: 'acr:10.0.0.1'
                    locationEventCriteria:
                      - ENTERING_AREA_EVENT
      parameters:
        - $ref: '#/components/parameters/Path.SubscrId'
      responses:
        '200':
          description: 'Upon success, a response body containing data type describing the updated subscription is returned. '
          content:
            application/json:
              schema:
                type: object
                properties:
                  userLocationEventSubscription:
                    $ref: '#/components/schemas/UserLocationEventSubscription'
                  userLocationPeriodicSubscription:
                    $ref: '#/components/schemas/UserLocationPeriodicSubscription'
                example:
                  - userLocationEventSubscription:
                      subscriptionType: 'UserLocationEventSubscription'
                      callbackReference: 'http://my.callback.com/user-location-notification/some-id'
                      address: 'acr:10.0.0.1'
                      locationEventCriteria:
                        - ENTERING_AREA_EVENT
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '412':
          $ref: '#/components/responses/412'
        '422':
          $ref: '#/components/responses/422'
        '429':
          $ref: '#/components/responses/429'
      x-swagger-router-controller: 'subscriptions'

    delete:
      tags:
        - 'location'
      summary: 'Cancel a subscription'
      description: 'The DELETE method is used to cancel the existing subscription.'
      operationId: userSubDELETE
      parameters:
        - $ref: '#/components/parameters/Path.SubscrId'
      responses:
        '204':
          $ref: '#/components/responses/204'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '429':
          $ref: '#/components/responses/429'
      x-swagger-router-controller: 'subscriptions'

  /subscriptions/userTracking:
    get:
@@ -1334,6 +1461,38 @@ paths:
        '429':
          $ref: '#/components/responses/429'
      x-swagger-router-controller: 'subscriptions'
  /subscriptions/zones:
    get:
      tags:
        - 'location'
      summary: 'Retrieves all active subscriptions to zone notifications'
      description: 'This operation is used for retrieving all active subscriptions to zone notifications.'
      operationId: zoneSubListGET
      parameters:
        - $ref: '#/components/parameters/Query.Subscription_type_3'
        - $ref: '#/components/parameters/Query.ZoneId_2'
      responses:
        '200':
          description: "Upon success, a response body containing the list of links to requestor's subscriptions is returned."
          content:
            application/json:
              schema:
                type: object
                required:
                  - notificationSubscriptionList
                properties:
                  notificationSubscriptionList:
                    $ref: '#/components/schemas/InlineNotificationSubscriptionList'
                example:
                  - notificationSubscriptionList:
                      subscription:
                        - href: 'http://meAppServer.example.com/location/v2/subscriptions/zones/subscription123'
                          subscriptionType: 'ZoneLocationEventSubscription'
                        - href: 'http://meAppServer.example.com/location/v2/subscriptions/zones/subscription456'
                          subscriptionType: 'ZoneStatusSubscription'
                      resourceURL:
                          href: 'http://meAppServer.example.com/location/v2/subscriptions/zones'

  /subscriptions/zonalTraffic:
    get:
      tags:
@@ -1913,6 +2072,25 @@ components:
        items:
          type: string
      x-exportParamName: AccessPointId
    Query.Subscription_type_3:
      name: subscription_type
      in: query
      description: "Query parameter to filter on a specific subscription type. Permitted values:
        -event
        -status"
      required: false
      schema:
        type: string
      x-exportParamName: Subscription_type_3
    Query.ZoneId_2:
      name: zoneId
      in: query
      description: The identity of the zone
      required: false
      schema:
        type: string
      x-exportParamName: ZoneId_2

    Query.Address:
      name: address
      in: query
@@ -2113,6 +2291,155 @@ components:
      x-etsi-notes: "NOTE 1:\tAt least one of callbackReference and websockNotifConfig shall be provided by the service consumer. If both are provided, it is up to location server to select an alternative and return only that alternative in the response, as specified in ETSI GS MEC 009 [4], clause 6.12a.\nNOTE 2:\tThis allows the client to recover from communication failures during resource creation and therefore avoids duplicate subscription creation in such situations. In case the element is present, the server shall not alter its value, and shall provide it as part of the representation of this resource. In case the element is not present, the server shall not generate it.\nNOTE 3:\tAs specified in [17], clause 6.1.6.2.24."
      x-etsi-ref: 6.3.5

    ZoneStatusSubscription:
      properties:
        # _links:
        #   $ref: '#/components/schemas/_links'
        callbackReference:
          description: URI exposed by the client on which to receive notifications via HTTP. See note 1.
          format: uri
          type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: Uri
        clientCorrelator:
          description: A correlator that the client can use to tag this particular resource representation during a request to create a resource on the server. See note 2.
          type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
        expiryDeadline:
          description': The expiration time of the subscription determined by the Zone Status Service.
          x-etsi-mec-cardinality': 0..1
          x-etsi-mec-origin-type': TimeStamp
          $ref: '#/components/schemas/TimeStamp'
        lowerNumberOfUsersAPThreshold:
          description: Threshold number of users in an access point which if crossed downward shall cause a notification
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        lowerNumberOfUsersZoneThreshold:
          description: Threshold number of users in a zone which if crossed downward shall cause a notification
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        operationStatus:
          description: List of operation status values to generate notifications for (these apply to all access points within a zone). See note 3.
          items:
            $ref: '#/components/schemas/OperationStatus'
          minItems: 0
          type: array
          x-etsi-mec-cardinality: 0..N
          x-etsi-mec-origin-type: OperationStatus
        reportingCtrl:
          description': Provides parameters that ctrl the reporting.
          x-etsi-mec-cardinality': 0..1
          x-etsi-mec-origin-type': ReportingCtrl
          $ref: '#/components/schemas/ReportingCtrl'
        requestTestNotification:
          description: "Set to TRUE by the service consumer to request a test notification via HTTP on the callbackReference URI, as specified in ETSI GS\_MEC 009 [4], clause 6.12a."
          type: boolean
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: Boolean
        subscriptionType:
          description: Shall be set to "ZoneStatusSubscription".
          type: string
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: String
        upperNumberOfUsersAPThreshold:
          description: Threshold number of users in an access point which if crossed upward shall cause a notification.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        upperNumberOfUsersZoneThreshold:
          description: Threshold number of users in a zone which if crossed upward shall cause a notification.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        websockNotifConfig:
          description': Provides details to negotiate and signal the use of a Websocket connection between the location server and the service consumer for notifications. See note 1.
          x-etsi-mec-cardinality': 0..1
          x-etsi-mec-origin-type': WebsockNotifConfig
          $ref: '#/components/schemas/WebsockNotifConfig'
        zoneId:
          description: Identifier of zone (e.g. zone001) to monitor.
          type: string
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: String
      required:
      - subscriptionType
      - zoneId
      type: object
      x-etsi-notes: "NOTE 1:\tAt least one of callbackReference and websockNotifConfig shall be provided by the service consumer. If both are provided, it is up to location server to select an alternative and return only that alternative in the response, as specified in ETSI GS MEC 009 [4], clause 6.12a.\nNOTE 2:\tThis allows the client to recover from communication failures during resource creation and therefore avoids duplicate subscription creation in such situations. In case the element is present, the server shall not alter its value, and shall provide it as part of the representation of this resource. In case the element is not present, the server shall not generate it.\nNOTE 3:\tAs specified in [5], clause 5.2.3.2."
      x-etsi-ref: 6.3.7


    ZoneLocationEventSubscription:
      properties:
        # _links:
        #   $ref: '#/components/schemas/_links'
        addressList:
          description: List of the users to be monitored. If not present, all the users need to be monitored.
          items:
            type: string
          minItems: 0
          type: array
          x-etsi-mec-cardinality: 0..N
          x-etsi-mec-origin-type: Array(Uri)
        callbackReference:
          description: URI exposed by the client on which to receive notifications via HTTP. See note 1.
          format: uri
          type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: Uri
        clientCorrelator:
          description: A correlator that the client can use to tag this particular resource representation during a request to create a resource on the server. See note 2.
          type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
        expiryDeadline:
          description': The expiration time of the subscription determined by the Zone Location Event Service.
          x-etsi-mec-cardinality': 0..1
          x-etsi-mec-origin-type': TimeStamp
          $ref: '#/components/schemas/TimeStamp'
        locationEventCriteria:
          description: 'List of user event values to generate notifications for. '
          items:
            $ref: '#/components/schemas/LocationEventType'
          minItems: 0
          type: array
          x-etsi-mec-cardinality: 0..N
          x-etsi-mec-origin-type: Array(LocationEventType)
        reportingCtrl:
          description': Provides parameters that ctrl the reporting.
          x-etsi-mec-cardinality': 0..1
          x-etsi-mec-origin-type': ReportingCtrl
          $ref: '#/components/schemas/ReportingCtrl'
        requestTestNotification:
          description: "Set to TRUE by the service consumer to request a test notification via HTTP on the callbackReference URI, as specified in ETSI GS\_MEC 009 [4], clause 6.12a."
          type: boolean
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: Boolean
        subscriptionType:
          description: Shall be set to "ZoneLocationEventSubscription".
          type: string
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: String
        websockNotifConfig:
          description': Provides details to negotiate and signal the use of a Websocket connection between the location server and the service consumer for notifications. See note 1.
          x-etsi-mec-cardinality': 0..1
          x-etsi-mec-origin-type': WebsockNotifConfig
          $ref: '#/components/schemas/WebsockNotifConfig'
        zoneId:
          description: Identifier of zone (e.g. zone001) to monitor.
          type: string
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: String
      required:
      - subscriptionType
      - zoneId
      type: object
      x-etsi-notes: "NOTE 1:\tAt least one of callbackReference and websockNotifConfig shall be provided by the service consumer. If both are provided, it is up to location server to select an alternative and return only that alternative in the response, as specified in ETSI GS MEC 009 [4], clause 6.12a.\nNOTE 2:\tThis allows the client to recover from communication failures during resource creation and therefore avoids duplicate subscription creation in such situations. In case the element is present, the server shall not alter its value, and shall provide it as part of the representation of this resource. In case the element is not present, the server shall not generate it."
      x-etsi-ref: 6.3.6


    UserLocationEventSubscription:
      properties:
@@ -2746,6 +3073,12 @@ components:
      type: string
    NotificationSubscriptionList:
      properties:
        zoneStatusSubscription:
          items:
            $ref: '#/components/schemas/ZoneStatusSubscription'
        zoneLocationEventSubscription:
          items:
            $ref: '#/components/schemas/ZoneLocationEventSubscription'
        userLocationEventSubscription:
          items:
            $ref: '#/components/schemas/UserLocationEventSubscription'
@@ -2798,14 +3131,6 @@ components:
          type: array
          x-etsi-mec-cardinality: 0.. N
          x-etsi-mec-origin-type: ZonalTrafficSubscription
        zoneStatusSubscription:
          description: Collection of ZoneStatusSubscription elements, see note 1.
          items:
            $ref: '#/components/schemas/ZoneStatusSubscription'
          minItems: 0
          type: array
          x-etsi-mec-cardinality: 0.. N
          x-etsi-mec-origin-type: ZoneStatusSubscription
      required:
        - resourceURL
      type: object
@@ -3010,6 +3335,27 @@ components:
        - LEAVING_AREA_EVENT
      type: string

    ReportingCtrl:
      properties:
        maximumCount:
          description: Maximum number of notifications. For no maximum, either do not include this element or specify a value of zero. Default value is 0.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        maximumFrequency:
          description: Maximum frequency (in seconds) of notifications per subscription.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        minimumInterval:
          description: Minimum interval between reports in case frequently reporting. Unit is second.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
      type: object
      x-etsi-ref: 6.5.6


    PeriodicEventInfo:
      description: "NOTE: reportingAmount x reportingInterval shall not exceed 8639999 (99 days, 23 hours, 59 minutes and 59 seconds)
        for compatibility with OMA MLP and RLP." 
@@ -3545,47 +3891,47 @@ components:
        - zoneId
        - timestamp
      type: object
    ZoneStatusSubscription:
      description: A type containing zone status subscription.
      properties:
        callbackReference:
          $ref: '#/components/schemas/CallbackReference'
        clientCorrelator:
          description: A correlator that the client can use to tag this particular resource representation during a request to create a resource on the server.
          type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: string
        numberOfUsersAPThreshold:
          description: Threshold number of users in an access point which if crossed shall cause a notification
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: unsignedInt
        numberOfUsersZoneThreshold:
          description: Threshold number of users in a zone which if crossed shall cause a notification
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: unsignedInt
        operationStatus:
          description: List of operation status values to generate notifications for (these apply to all access points within a zone).
          items:
            $ref: '#/components/schemas/OperationStatus'
          type: array
          x-etsi-mec-cardinality: 0..N
          x-etsi-mec-origin-type: OperationStatus
        resourceURL:
          description: Self referring URL
          type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: anyURI
        zoneId:
          description: Identifier of zone
          type: string
          x-etsi-mec-cardinality: 1
          x-etsi-mec-origin-type: string
      required:
        - callbackReference
        - zoneId
      type: object
    # ZoneStatusSubscription:
    #   description: A type containing zone status subscription.
    #   properties:
    #     callbackReference:
    #       $ref: '#/components/schemas/CallbackReference'
    #     clientCorrelator:
    #       description: A correlator that the client can use to tag this particular resource representation during a request to create a resource on the server.
    #       type: string
    #       x-etsi-mec-cardinality: 0..1
    #       x-etsi-mec-origin-type: string
    #     numberOfUsersAPThreshold:
    #       description: Threshold number of users in an access point which if crossed shall cause a notification
    #       type: integer
    #       x-etsi-mec-cardinality: 0..1
    #       x-etsi-mec-origin-type: unsignedInt
    #     numberOfUsersZoneThreshold:
    #       description: Threshold number of users in a zone which if crossed shall cause a notification
    #       type: integer
    #       x-etsi-mec-cardinality: 0..1
    #       x-etsi-mec-origin-type: unsignedInt
    #     operationStatus:
    #       description: List of operation status values to generate notifications for (these apply to all access points within a zone).
    #       items:
    #         $ref: '#/components/schemas/OperationStatus'
    #       type: array
    #       x-etsi-mec-cardinality: 0..N
    #       x-etsi-mec-origin-type: OperationStatus
    #     resourceURL:
    #       description: Self referring URL
    #       type: string
    #       x-etsi-mec-cardinality: 0..1
    #       x-etsi-mec-origin-type: anyURI
    #     zoneId:
    #       description: Identifier of zone
    #       type: string
    #       x-etsi-mec-cardinality: 1
    #       x-etsi-mec-origin-type: string
    #   required:
    #     - callbackReference
    #     - zoneId
    #   type: object
    InlineAccessPointInfo:
      type: object
      properties:
+4 −0
Original line number Diff line number Diff line
@@ -157,6 +157,10 @@ func ZonalTrafficSubListGET(w http.ResponseWriter, r *http.Request) {
	zonalTrafficSubListGet(w, r)
}

func ZoneSubListGET(w http.ResponseWriter, r *http.Request) {
	zoneSubListGET(w, r)
}

func ZonalTrafficSubPOST(w http.ResponseWriter, r *http.Request) {
	zonalTrafficSubPost(w, r)
}
+25 −2
Original line number Diff line number Diff line
@@ -3680,7 +3680,30 @@ func zonalTrafficSubDelete(w http.ResponseWriter, r *http.Request) {
	deregisterZonal(vars["subscriptionId"])
	w.WriteHeader(http.StatusNoContent)
}
func zoneSubListGET(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json; charset=UTF-8")

	var response InlineNotificationSubscriptionList
	var zonalSubList NotificationSubscriptionList
	zonalSubList.ResourceURL = hostUrl.String() + basePath + "subscriptions/zones"
	response.NotificationSubscriptionList = &zonalSubList

	keyName := baseKey + typeZonalSubscription + "*"
	err := rc.ForEachJSONEntry(keyName, populateZonalTrafficList, &zonalSubList)
	if err != nil {
		log.Error(err.Error())
		errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError)
		return
	}
	jsonResponse, err := json.Marshal(response)
	if err != nil {
		log.Error(err.Error())
		errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError)
		return
	}
	w.WriteHeader(http.StatusOK)
	fmt.Fprint(w, string(jsonResponse))
}
func zonalTrafficSubListGet(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json; charset=UTF-8")

@@ -3888,14 +3911,14 @@ func zonalTrafficSubPut(w http.ResponseWriter, r *http.Request) {
func populateZonalTrafficList(key string, jsonInfo string, userData interface{}) error {

	zoneList := userData.(*NotificationSubscriptionList)
	var zoneInfo ZonalTrafficSubscription
	var zoneInfo ZoneLocationEventSubscription

	// Format response
	err := json.Unmarshal([]byte(jsonInfo), &zoneInfo)
	if err != nil {
		return err
	}
	zoneList.ZonalTrafficSubscription = append(zoneList.ZonalTrafficSubscription, zoneInfo)
	zoneList.ZoneLocationEventSubscription = append(zoneList.ZoneLocationEventSubscription, zoneInfo)
	return nil
}

+4 −1
Original line number Diff line number Diff line
@@ -24,8 +24,12 @@
package server

type NotificationSubscriptionList struct {
	ZoneStatusSubscription []ZoneStatusSubscription `json:"zoneStatusSubscription,omitempty"`

	UserLocationEventSubscription []UserLocationEventSubscription `json:"userLocationEventSubscription,omitempty"`

	ZoneLocationEventSubscription []ZoneLocationEventSubscription `json:"zoneLocationEventSubscription,omitempty"`

	UserLocationPeriodicSubscription []UserLocationPeriodicSubscription `json:"UserLocationPeriodicSubscription,omitempty"`
	// Collection of CircleNotificationSubscription elements, see note 2.
	CircleNotificationSubscription []CircleNotificationSubscription `json:"circleNotificationSubscription,omitempty"`
@@ -40,5 +44,4 @@ type NotificationSubscriptionList struct {
	// Collection of ZonalTrafficSubscription elements, see note 1.
	ZonalTrafficSubscription []ZonalTrafficSubscription `json:"zonalTrafficSubscription,omitempty"`
	// Collection of ZoneStatusSubscription elements, see note 1.
	ZoneStatusSubscription []ZoneStatusSubscription `json:"zoneStatusSubscription,omitempty"`
}
+19 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading