/AWS1/IF_SDY=>DISCOVERINSTANCES()¶
About DiscoverInstances¶
Discovers registered instances for a specified namespace and service. You can use
DiscoverInstances to discover instances for any type of namespace.
DiscoverInstances returns a randomized list of instances allowing customers to
distribute traffic evenly across instances. For public and private DNS namespaces, you can also
use DNS queries to discover instances.
Method Signature¶
METHODS /AWS1/IF_SDY~DISCOVERINSTANCES
IMPORTING
!IV_NAMESPACENAME TYPE /AWS1/SDYNAMESPACENAME OPTIONAL
!IV_SERVICENAME TYPE /AWS1/SDYSERVICENAME OPTIONAL
!IV_MAXRESULTS TYPE /AWS1/SDYDISCOVERMAXRESULTS OPTIONAL
!IT_QUERYPARAMETERS TYPE /AWS1/CL_SDYATTRIBUTES_W=>TT_ATTRIBUTES OPTIONAL
!IT_OPTIONALPARAMETERS TYPE /AWS1/CL_SDYATTRIBUTES_W=>TT_ATTRIBUTES OPTIONAL
!IV_HEALTHSTATUS TYPE /AWS1/SDYHEALTHSTATUSFILTER OPTIONAL
!IV_OWNERACCOUNT TYPE /AWS1/SDYAWSACCOUNTID OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_sdydiscoverinstsrsp
RAISING
/AWS1/CX_SDYINVALIDINPUT
/AWS1/CX_SDYNAMESPACENOTFOUND
/AWS1/CX_SDYREQUESTLIMITEXCD
/AWS1/CX_SDYSERVICENOTFOUND
/AWS1/CX_SDYCLIENTEXC
/AWS1/CX_SDYSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_namespacename TYPE /AWS1/SDYNAMESPACENAME /AWS1/SDYNAMESPACENAME¶
The
HttpNamename of the namespace. TheHttpNameis found in theHttpPropertiesmember of thePropertiesmember of the namespace. In most cases,NameandHttpNamematch. However, if you reuseNamefor namespace creation, a generated hash is added toHttpNameto distinguish the two.
iv_servicename TYPE /AWS1/SDYSERVICENAME /AWS1/SDYSERVICENAME¶
The name of the service that you specified when you registered the instance.
Optional arguments:¶
iv_maxresults TYPE /AWS1/SDYDISCOVERMAXRESULTS /AWS1/SDYDISCOVERMAXRESULTS¶
The maximum number of instances that you want Cloud Map to return in the response to a
DiscoverInstancesrequest. If you don't specify a value forMaxResults, Cloud Map returns up to 100 instances.
it_queryparameters TYPE /AWS1/CL_SDYATTRIBUTES_W=>TT_ATTRIBUTES TT_ATTRIBUTES¶
Filters to scope the results based on custom attributes for the instance (for example,
{version=v1, az=1a}). Only instances that match all the specified key-value pairs are returned.
it_optionalparameters TYPE /AWS1/CL_SDYATTRIBUTES_W=>TT_ATTRIBUTES TT_ATTRIBUTES¶
Opportunistic filters to scope the results based on custom attributes. If there are instances that match both the filters specified in both the
QueryParametersparameter and this parameter, all of these instances are returned. Otherwise, the filters are ignored, and only instances that match the filters that are specified in theQueryParametersparameter are returned.
iv_healthstatus TYPE /AWS1/SDYHEALTHSTATUSFILTER /AWS1/SDYHEALTHSTATUSFILTER¶
The health status of the instances that you want to discover. This parameter is ignored for services that don't have a health check configured, and all instances are returned.
- HEALTHY
Returns healthy instances.
- UNHEALTHY
Returns unhealthy instances.
- ALL
Returns all instances.
- HEALTHY_OR_ELSE_ALL
Returns healthy instances, unless none are reporting a healthy state. In that case, return all instances. This is also called failing open.
iv_owneraccount TYPE /AWS1/SDYAWSACCOUNTID /AWS1/SDYAWSACCOUNTID¶
The ID of the Amazon Web Services account that owns the namespace associated with the instance, as specified in the namespace
ResourceOwnerfield. For instances associated with namespaces that are shared with your account, you must specify anOwnerAccount.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_sdydiscoverinstsrsp /AWS1/CL_SDYDISCOVERINSTSRSP¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->discoverinstances(
it_optionalparameters = VALUE /aws1/cl_sdyattributes_w=>tt_attributes(
(
VALUE /aws1/cl_sdyattributes_w=>ts_attributes_maprow(
key = |string|
value = new /aws1/cl_sdyattributes_w( |string| )
)
)
)
it_queryparameters = VALUE /aws1/cl_sdyattributes_w=>tt_attributes(
(
VALUE /aws1/cl_sdyattributes_w=>ts_attributes_maprow(
key = |string|
value = new /aws1/cl_sdyattributes_w( |string| )
)
)
)
iv_healthstatus = |string|
iv_maxresults = 123
iv_namespacename = |string|
iv_owneraccount = |string|
iv_servicename = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
LOOP AT lo_result->get_instances( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lv_resourceid = lo_row_1->get_instanceid( ).
lv_namespacenamehttp = lo_row_1->get_namespacename( ).
lv_servicename = lo_row_1->get_servicename( ).
lv_healthstatus = lo_row_1->get_healthstatus( ).
LOOP AT lo_row_1->get_attributes( ) into ls_row_2.
lv_key = ls_row_2-key.
lo_value = ls_row_2-value.
IF lo_value IS NOT INITIAL.
lv_attrvalue = lo_value->get_value( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
lv_revision = lo_result->get_instancesrevision( ).
ENDIF.
Discover instances using owner account¶
Discovers instances in a shared namespace by specifying the OwnerAccount parameter, useful when working with shared namespaces.
DATA(lo_result) = lo_client->discoverinstances(
iv_namespacename = |example-shared-namespace|
iv_owneraccount = |123456789012|
iv_servicename = |shared-namespace-service|
).
Example: Discover registered instances¶
Example: Discover registered instances
DATA(lo_result) = lo_client->discoverinstances(
iv_healthstatus = |ALL|
iv_maxresults = 10
iv_namespacename = |example.com|
iv_servicename = |myservice|
).