You are working on a project that involves managing AWS resources using Python. Specifically, you need to implement a class that handles AWS Serverless APIs. The class is responsible for storing and retrieving APIs based on their logical ID.

Your task is to complete the implementation of the `add_apis` method of the `ServerlessAPI` class. This method should store the given APIs under the specified logical ID. 

The `add_apis` method takes two parameters:
- `logical_id` (str): The logical ID of the AWS::Serverless::Api resource.
- `apis` (list of samcli.commands.local.lib.provider.Api): A list of APIs available in this resource.

Your implementation should ensure that when the `add_apis` method is called multiple times with the same logical ID, the APIs are appended to the existing list of APIs.

You need to write the code for the `add_apis` method to fulfill the following requirements:
1. If the logical ID is not present in the class instance's internal dictionary `self.by_resource`, create a new entry with the logical ID as the key and an empty list as the value.
2. Append each API in the `apis` list to the list of APIs associated with the logical ID.

Note:
- You can assume that the `add_apis` method will always be called with valid inputs.

Complete the implementation of the `ServerlessAPI` class by writing the `add_apis` method.
user
Sure, here's how you can implement the `add_apis` method in your `ServerlessAPI` class to meet the given requirements. This assumes that you have already added a `by_resource` dictionary to your class to store resources with logical IDs:

```python
class ServerlessAPI:
    def __init__(self):
        self.by_resource = {}

    def add_apis(self, logical_id, apis):
        if logical_id not in self.by_resource:
            self.by_resource[logical_id] = []

        for api in apis:
            self.by_resource[logical_id].append(api)
```

This implementation first checks if the logical ID is already present in the `by_resource` dictionary. If it's not, a new key-value pair is added with an empty list as the value. If it's present, the API is appended to the existing list.

Note that this assumes that the API objects you're working with have a `__repr__` method that returns a string that looks like a Sam CLI API, so it can be appended correctly to the list. If this isn't the case, you'll need to modify the method accordingly to handle your API objects.
assistant
You are working on a project that involves managing AWS resources using Python. Specifically, you need to implement a class that handles AWS Serverless APIs. The class is responsible for storing and retrieving APIs based on their logical ID.

Your task is to complete the implementation of the `add_apis` method of the `ServerlessAPI` class. This method should store the given APIs under the specified logical ID. 

The `add_apis` method takes two parameters:
- `logical_id` (str): The logical ID of the AWS::Serverless::Api resource.
- `apis` (list of samcli.commands.local.lib.provider.Api): A list of APIs available in this resource.

Your implementation should ensure that when the `add_apis` method is called multiple times with the same logical ID, the APIs are appended to the existing list of APIs.

You need to write the code for the `add_apis` method to fulfill the following requirements:
1. If the logical ID is not present in the class instance's internal dictionary `self.by_resource`, create a new entry with the logical ID as the key and an empty list as the value.
2. Append each API in the `apis` list to the list of APIs associated with the logical ID.

Note:
- You can assume that the `add_apis` method will always be called with valid inputs.

Complete the implementation of the `ServerlessAPI` class by writing the `add_apis` method.
user
Sure, I can help you with that. Here's how you can implement the `add_apis` method in the `ServerlessAPI` class:

```python
class ServerlessAPI:
    def __init__(self):
        self.by_resource = {}

    def add_apis(self, logical_id, apis):
        # If the logical ID is not present in the class instance's internal dictionary, create a new entry with the logical ID as the key and an empty list as the value.
        if logical_id not in self.by_resource:
            self.by_resource[logical_id] = []

        # Append each API in the apis list to the list of APIs associated with the logical ID.
        for api in apis:
            self.by_resource[logical_id].append(api)
```

This implementation ensures that when the `add_apis` method is called multiple times with the same logical ID, the APIs are appended to the existing list of APIs.
assistant