Use DescribeServices with an AWS SDK or CLI - AWS Support

Use DescribeServices with an AWS SDK or CLI

The following code examples show how to use DescribeServices.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

.NET
AWS SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

/// <summary> /// Get the descriptions of AWS services. /// </summary> /// <param name="name">Optional language for services. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <returns>The list of AWS service descriptions.</returns> public async Task<List<Service>> DescribeServices(string language = "en") { var response = await _amazonSupport.DescribeServicesAsync( new DescribeServicesRequest() { Language = language }); return response.Services; }
CLI
AWS CLI

To list AWS services and service categories

The following describe-services example lists the available service categories for requesting general information.

aws support describe-services \ --service-code-list "general-info"

Output:

{ "services": [ { "code": "general-info", "name": "General Info and Getting Started", "categories": [ { "code": "charges", "name": "How Will I Be Charged?" }, { "code": "gdpr-queries", "name": "Data Privacy Query" }, { "code": "reserved-instances", "name": "Reserved Instances" }, { "code": "resource", "name": "Where is my Resource?" }, { "code": "using-aws", "name": "Using AWS & Services" }, { "code": "free-tier", "name": "Free Tier" }, { "code": "security-and-compliance", "name": "Security & Compliance" }, { "code": "account-structure", "name": "Account Structure" } ] } ] }

For more information, see Case management in the AWS Support User Guide.

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

// Return a List that contains a Service name and Category name. public static List<String> displayServices(SupportClient supportClient) { try { DescribeServicesRequest servicesRequest = DescribeServicesRequest.builder() .language("en") .build(); DescribeServicesResponse response = supportClient.describeServices(servicesRequest); String serviceCode = null; String catName = null; List<String> sevCatList = new ArrayList<>(); List<Service> services = response.services(); System.out.println("Get the first 10 services"); int index = 1; for (Service service : services) { if (index == 11) break; System.out.println("The Service name is: " + service.name()); if (service.name().compareTo("Account") == 0) serviceCode = service.code(); // Get the Categories for this service. List<Category> categories = service.categories(); for (Category cat : categories) { System.out.println("The category name is: " + cat.name()); if (cat.name().compareTo("Security") == 0) catName = cat.name(); } index++; } // Push the two values to the list. sevCatList.add(serviceCode); sevCatList.add(catName); return sevCatList; } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return null; }
Kotlin
SDK for Kotlin
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

// Return a List that contains a Service name and Category name. suspend fun displayServices(): List<String> { var serviceCode = "" var catName = "" val sevCatList = mutableListOf<String>() val servicesRequest = DescribeServicesRequest { language = "en" } SupportClient { region = "us-west-2" }.use { supportClient -> val response = supportClient.describeServices(servicesRequest) println("Get the first 10 services") var index = 1 response.services?.forEach { service -> if (index == 11) { return@forEach } println("The Service name is ${service.name}") if (service.name == "Account") { serviceCode = service.code.toString() } // Get the categories for this service. service.categories?.forEach { cat -> println("The category name is ${cat.name}") if (cat.name == "Security") { catName = cat.name!! } } index++ } } // Push the two values to the list. serviceCode.let { sevCatList.add(it) } catName.let { sevCatList.add(it) } return sevCatList }
PowerShell
Tools for PowerShell

Example 1: Returns all available service codes, names and categories.

Get-ASAService

Example 2: Returns the name and categories for the service with the specified code.

Get-ASAService -ServiceCodeList "amazon-cloudfront"

Example 3: Returns the name and categories for the specified service codes.

Get-ASAService -ServiceCodeList @("amazon-cloudfront", "amazon-cloudwatch")

Example 4: Returns the name and categories (in Japanese) for the specified service codes. Currently English ("en") and Japanese ("ja") language codes are supported.

Get-ASAService -ServiceCodeList @("amazon-cloudfront", "amazon-cloudwatch") -Language "ja"
  • For API details, see DescribeServices in AWS Tools for PowerShell Cmdlet Reference.

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

class SupportWrapper: """Encapsulates Support actions.""" def __init__(self, support_client): """ :param support_client: A Boto3 Support client. """ self.support_client = support_client @classmethod def from_client(cls): """ Instantiates this class from a Boto3 client. """ support_client = boto3.client("support") return cls(support_client) def describe_services(self, language): """ Get the descriptions of AWS services available for support for a language. :param language: The language for support services. Currently, only "en" (English) and "ja" (Japanese) are supported. :return: The list of AWS service descriptions. """ try: response = self.support_client.describe_services(language=language) services = response["services"] except ClientError as err: if err.response["Error"]["Code"] == "SubscriptionRequiredException": logger.info( "You must have a Business, Enterprise On-Ramp, or Enterprise Support " "plan to use the AWS Support API. \n\tPlease upgrade your subscription to run these " "examples." ) else: logger.error( "Couldn't get Support services for language %s. Here's why: %s: %s", language, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return services
  • For API details, see DescribeServices in AWS SDK for Python (Boto3) API Reference.

For a complete list of AWS SDK developer guides and code examples, see Using AWS Support with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.