Module: UU::OS::QoS

Extended by:
QoS
Included in:
QoS
Defined in:
uu_os_framework-0.29.16/lib/uu/os/qos.rb,
uu_os_framework-0.29.16/lib/uu/os/qos/qos_handler.rb,
uu_os_framework-0.29.16/lib/uu/os/qos/territory_get_qos.rb,
uu_os_framework-0.29.16/lib/uu/os/qos/territory_set_qos.rb,
uu_os_framework-0.29.16/lib/uu/os/qos/access_role_set_qos.rb,
uu_os_framework-0.29.16/lib/uu/os/qos/access_role_get_qos.rb,
uu_os_framework-0.29.16/lib/uu/os/qos/qos_limit_exception.rb

Overview

The QoS service is used for getting and setting a QoS to the access roles or territory.

Defined Under Namespace

Modules: QoSHandler Classes: AccessRoleGetQoS, AccessRoleSetQoS, QoSLimitException, TerritoryGetQoS, TerritorySetQoS

Constant Summary

PATH =

Service path

'/ues/core/qos/UESQoS'

Instance Method Summary (collapse)

Instance Method Details

- (UU::OS::QoS::AccessRoleGetQoS) get_access_role_qos(acr_uri)

Returns a DTO representing QoS for a specific access role. The values represents a requests limit per particular period. Special values are 0 (no request is allowed) and -1 (unlimited).

Examples:

# access role uri
acr_uri = 'ues:UNI:9999-1'

# get QoS for access role
qos = UU::OS::QoS.get_access_role_qos(acr_uri)

# get values for a particular period
qos.minute_rate # 100 (max 100 requests per minute)
qos.hour_rate   # -1 (no limit = infinite number of requests per hour)
qos.day_rate    # 1000 (max 1000 requests per day)
qos.week_rate   # -1
qos.month_rate  # -1
qos.year_rate   # -1

Parameters:

  • acr_uri (UU::OS::UESURI)

    UESURI of the access role for which QoS will be returned.

Returns:



120
121
122
123
124
125
126
127
128
129
# File 'uu_os_framework-0.29.16/lib/uu/os/qos.rb', line 120

def get_access_role_qos(acr_uri)

  svc = UU::OS::REST::RemoteClient.new(QoS)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get(:getAccessRoleQoS, acr_uri)
    if !(res.nil? || res.empty?)
      return UU::OS::QoS::AccessRoleGetQoS.new(res)
    end
  end
end

- (UU::OS::QoS::TerritoryGetQoS) get_territory_qos(territory_uri)

Returns a DTO representing QoS for a specific territory. The values represents a requests limit per particular period. Special values are 0 (no request is allowed) and -1 (unlimited).

Examples:

# territory uri
territory_uri = 'ues:UNI:UNI'

# get QoS for territory
qos = UU::OS::QoS.get_territory_qos(territory_uri)

# get values for a particular period
qos.minute_rate # 1000 (max 1000 requests per minute)
qos.hour_rate   # -1 (no limit = infinite number of requests per hour)
qos.day_rate    # 10000 (max 10000 requests per day)
qos.week_rate   # -1
qos.month_rate  # -1
qos.year_rate   # -1

Parameters:

  • territory_uri (UU::OS::UESURI)

    UESURI of the territory for which QoS will be returned.

Returns:



36
37
38
39
40
41
42
43
44
45
46
# File 'uu_os_framework-0.29.16/lib/uu/os/qos.rb', line 36

def get_territory_qos(territory_uri)

  svc = UU::OS::REST::RemoteClient.new(QoS)

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get(:getTerritoryQoS, territory_uri)
    if !(res.nil? || res.empty?)
      return UU::OS::QoS::TerritoryGetQoS.new(res)
    end
  end
end

- (void) set_access_role_qos(acr_uri, qos = nil)

This method returns an undefined value.

Sets QoS for a specific access role. You must specify at least one value from AccessRoleSetQoS DTO provided as parameter 'qos'. If you don't define some values in the DTO, so they stay untouched for existing QoS limits. If no QoS exists for the access role, than new one is created and undefined parameters in DTO are set to -1 (unlimited). Special values are 0 (no request is allowed) and -1 (unlimited).

Examples:

# access role uri
acr_uri = 'ues:UNI:9999-1'

# set QoS to access role that has no limit set now, after this command QoS will be:
# year_rate: -1, month_rate: -1, week_rate: -1, day_rate: 2000, hour_rate: -1, minute_rate: 100
# If new QoS is created, unspecified periods are set to default -1 (unlimited)
UU::OS::QoS.set_access_role_qos(acr_uri, day_rate: 2000, minute_rate: 100)

# now set month_rate to same access role as above, after this command QoS will be:
# year_rate: -1, month_rate: 10000, week_rate: -1, day_rate: 2000, hour_rate: -1, minute_rate: 100
# If limit already exists for access role, unspecified periods stay untouched
UU::OS::QoS.set_access_role_qos(acr_uri, month_rate: 10000)

# if you want to forbid access to the territory for an access role, you must set at least one limit to 0 ( = no access allowed)
UU::OS::QoS.set_access_role_qos(acr_uri, year_rate: 0, month_rate: 0, week_rate: 0, day_rate: 0, hour_rate: 0, minute_rate: 0)

# set infinite QoS for access role
UU::OS::QoS.set_access_role_qos(acr_uri, year_rate: -1, month_rate: -1, week_rate: -1, day_rate: -1, hour_rate: -1, minute_rate: -1)

# you can also create whole DTO for setting QoS
qos = UU::OS::QoS::AccessRoleSetQoS.new(
  year_rate: -1,
  month_rate: -1,
  week_rate: -1,
  day_rate: 2000,
  hour_rate: -1,
  minute_rate: 100
)
UU::OS::QoS.set_access_role_qos(acr_uri, qos)

Parameters:



172
173
174
175
176
177
178
179
180
181
# File 'uu_os_framework-0.29.16/lib/uu/os/qos.rb', line 172

def set_access_role_qos(acr_uri, qos = nil)

  svc = UU::OS::REST::RemoteClient.new(QoS)
  dto = UU::OS::QoS::AccessRoleSetQoS.new(qos).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post(:setAccessRoleQoS, acr_uri, dto)
  end

end

- (void) set_territory_qos(territory_uri, qos = nil)

Note:

If you set at least one value to zero ( = 0, means all remote calls to territory are forbidden and ends up with QoS exception ) you will not be able to call this API for the territory anymore and set the QoS back. Setting QoS to zero isn’t what you probably want.

This method returns an undefined value.

Sets QoS for a specific territory. You must specify at least one value from TerritorySetQoS DTO provided as parameter 'qos'. If you don't define some values in the DTO so they stay untouched for existing QoS limits. If no QoS exists for the territory, than new one is created and undefined parameters in DTO are set to -1 (unlimited). Special values are 0 (no request is allowed) and -1 (unlimited).

Examples:

# territory uri
territory_uri = 'ues:UNI:UNI'

# set QoS to territory that has no limit set now, after this command QoS will be:
# year_rate: -1, month_rate: -1, week_rate: -1, day_rate: 2000, hour_rate: -1, minute_rate: 100
# If new QoS is created, unspecified periods are set to default -1 (unlimited)
UU::OS::QoS.set_territory_qos(territory_uri, day_rate: 2000, minute_rate: 100)

# now set month_rate to same territory as above, after this command QoS will be:
# year_rate: -1, month_rate: 10000, week_rate: -1, day_rate: 2000, hour_rate: -1, minute_rate: 100
# If limit already exists for territory, unspecified periods stay untouched
UU::OS::QoS.set_territory_qos(territory_uri, month_rate: 10000)

# set infinite QoS for territory
UU::OS::QoS.set_territory_qos(territory_uri, year_rate: -1, month_rate: -1, week_rate: -1, day_rate: -1, hour_rate: -1, minute_rate: -1)

# you can also create whole DTO for setting QoS
qos = UU::OS::QoS::TerritorySetQoS.new(
  year_rate: -1,
  month_rate: -1,
  week_rate: -1,
  day_rate: 20000,
  hour_rate: -1,
  minute_rate: 1000
)
UU::OS::QoS.set_territory_qos(territory_uri, qos)

Parameters:



88
89
90
91
92
93
94
95
96
# File 'uu_os_framework-0.29.16/lib/uu/os/qos.rb', line 88

def set_territory_qos(territory_uri, qos = nil)
  svc = UU::OS::REST::RemoteClient.new(QoS)

  dto = UU::OS::QoS::TerritorySetQoS.new(qos).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post(:setTerritoryQoS, territory_uri, dto)
  end
end