# TargetGroupsApi

## TargetGroupsApi

All URIs are relative to *<https://api.ionos.com/cloudapi/v6>*

| Method                                                                                 | HTTP request                             | Description                           |
| -------------------------------------------------------------------------------------- | ---------------------------------------- | ------------------------------------- |
| [**target\_groups\_delete**](#target_groups_delete)                                    | **DELETE** /targetgroups/{targetGroupId} | Delete a Target Group by ID           |
| [**targetgroups\_find\_by\_target\_group\_id**](#targetgroups_find_by_target_group_id) | **GET** /targetgroups/{targetGroupId}    | Get a Target Group by ID              |
| [**targetgroups\_get**](#targetgroups_get)                                             | **GET** /targetgroups                    | Get Target Groups                     |
| [**targetgroups\_patch**](#targetgroups_patch)                                         | **PATCH** /targetgroups/{targetGroupId}  | Partially Modify a Target Group by ID |
| [**targetgroups\_post**](#targetgroups_post)                                           | **POST** /targetgroups                   | Create a Target Group                 |
| [**targetgroups\_put**](#targetgroups_put)                                             | **PUT** /targetgroups/{targetGroupId}    | Modify a Target Group by ID           |

## **target\_groups\_delete**

> target\_groups\_delete(target\_group\_id, pretty=pretty, depth=depth, x\_contract\_number=x\_contract\_number)

Delete a Target Group by ID

Deletes the target group specified by its ID.

#### Example

```python
from __future__ import print_function
import time
import ionoscloud
from ionoscloud.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/cloudapi/v6
configuration = ionoscloud.Configuration(
    host = 'https://api.ionos.com/cloudapi/v6',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud.TargetGroupsApi(api_client)
    target_group_id = 'target_group_id_example' # str | The unique ID of the target group.
    try:
        # Delete a Target Group by ID
        api_instance.target_groups_delete(target_group_id)
    except ApiException as e:
        print('Exception when calling TargetGroupsApi.target_groups_delete: %s\n' % e)
```

#### Parameters

| Name                    | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                              | Notes                          |
| ----------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| **target\_group\_id**   | **str**  | The unique ID of the target group.                                                                                                                                                                                                                                                                                                                                                                                                       |                                |
| **pretty**              | **bool** | Controls whether the response is pretty-printed (with indentations and new lines).                                                                                                                                                                                                                                                                                                                                                       | \[optional] \[default to True] |
| **depth**               | **int**  | Controls the detail depth of the response objects. GET /datacenters/\[ID] - depth=0: Only direct properties are included; children (servers and other elements) are not included. - depth=1: Direct properties and children references are included. - depth=2: Direct properties and children properties are included. - depth=3: Direct properties and children properties and children's children are included. - depth=... and so on | \[optional] \[default to 0]    |
| **x\_contract\_number** | **int**  | Users with multiple contracts must provide the contract number, for which all API requests are to be executed.                                                                                                                                                                                                                                                                                                                           | \[optional]                    |

#### Return type

void (empty response body)

#### Authorization

Basic Authentication, Token Authentication

#### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## **targetgroups\_find\_by\_target\_group\_id**

> TargetGroup targetgroups\_find\_by\_target\_group\_id(target\_group\_id, pretty=pretty, depth=depth, x\_contract\_number=x\_contract\_number)

Get a Target Group by ID

Retrieves the properties of the target group specified by its ID.

#### Example

```python
from __future__ import print_function
import time
import ionoscloud
from ionoscloud.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/cloudapi/v6
configuration = ionoscloud.Configuration(
    host = 'https://api.ionos.com/cloudapi/v6',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud.TargetGroupsApi(api_client)
    target_group_id = 'target_group_id_example' # str | The unique ID of the target group.
    try:
        # Get a Target Group by ID
        api_response = api_instance.targetgroups_find_by_target_group_id(target_group_id)
        print(api_response)
    except ApiException as e:
        print('Exception when calling TargetGroupsApi.targetgroups_find_by_target_group_id: %s\n' % e)
```

#### Parameters

| Name                    | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                              | Notes                          |
| ----------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| **target\_group\_id**   | **str**  | The unique ID of the target group.                                                                                                                                                                                                                                                                                                                                                                                                       |                                |
| **pretty**              | **bool** | Controls whether the response is pretty-printed (with indentations and new lines).                                                                                                                                                                                                                                                                                                                                                       | \[optional] \[default to True] |
| **depth**               | **int**  | Controls the detail depth of the response objects. GET /datacenters/\[ID] - depth=0: Only direct properties are included; children (servers and other elements) are not included. - depth=1: Direct properties and children references are included. - depth=2: Direct properties and children properties are included. - depth=3: Direct properties and children properties and children's children are included. - depth=... and so on | \[optional] \[default to 0]    |
| **x\_contract\_number** | **int**  | Users with multiple contracts must provide the contract number, for which all API requests are to be executed.                                                                                                                                                                                                                                                                                                                           | \[optional]                    |

#### Return type

[**TargetGroup**](/python-sdk/models/targetgroup.md)

#### Authorization

Basic Authentication, Token Authentication

#### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## **targetgroups\_get**

> TargetGroups targetgroups\_get(pretty=pretty, depth=depth, x\_contract\_number=x\_contract\_number, offset=offset, limit=limit)

Get Target Groups

Lists target groups. A target group is a set of one or more registered targets. You must specify an IP address, a port number, and a weight for each target. Any object with an IP address in your VDC can be a target, for example, a VM, another load balancer, etc. You can register a target with multiple target groups.

#### Example

```python
from __future__ import print_function
import time
import ionoscloud
from ionoscloud.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/cloudapi/v6
configuration = ionoscloud.Configuration(
    host = 'https://api.ionos.com/cloudapi/v6',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud.TargetGroupsApi(api_client)
    try:
        # Get Target Groups
        api_response = api_instance.targetgroups_get()
        print(api_response)
    except ApiException as e:
        print('Exception when calling TargetGroupsApi.targetgroups_get: %s\n' % e)
```

#### Parameters

| Name                    | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                              | Notes                          |
| ----------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| **pretty**              | **bool** | Controls whether the response is pretty-printed (with indentations and new lines).                                                                                                                                                                                                                                                                                                                                                       | \[optional] \[default to True] |
| **depth**               | **int**  | Controls the detail depth of the response objects. GET /datacenters/\[ID] - depth=0: Only direct properties are included; children (servers and other elements) are not included. - depth=1: Direct properties and children references are included. - depth=2: Direct properties and children properties are included. - depth=3: Direct properties and children properties and children's children are included. - depth=... and so on | \[optional] \[default to 0]    |
| **x\_contract\_number** | **int**  | Users with multiple contracts must provide the contract number, for which all API requests are to be executed.                                                                                                                                                                                                                                                                                                                           | \[optional]                    |
| **offset**              | **int**  | The first element (from the complete list of the elements) to include in the response (used together with \<b>\<i>limit\</i>\</b> for pagination).                                                                                                                                                                                                                                                                                       | \[optional] \[default to 0]    |
| **limit**               | **int**  | The maximum number of elements to return (used together with \<b>\<i>offset\</i>\</b> for pagination). It must not exceed \<b>\<i>200\</i>\</b>.                                                                                                                                                                                                                                                                                         | \[optional] \[default to 100]  |

#### Return type

[**TargetGroups**](/python-sdk/models/targetgroups.md)

#### Authorization

Basic Authentication, Token Authentication

#### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## **targetgroups\_patch**

> TargetGroup targetgroups\_patch(target\_group\_id, target\_group\_properties, pretty=pretty, depth=depth, x\_contract\_number=x\_contract\_number)

Partially Modify a Target Group by ID

Updates the properties of the target group specified by its ID.

#### Example

```python
from __future__ import print_function
import time
import ionoscloud
from ionoscloud.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/cloudapi/v6
configuration = ionoscloud.Configuration(
    host = 'https://api.ionos.com/cloudapi/v6',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud.TargetGroupsApi(api_client)
    target_group_id = 'target_group_id_example' # str | The unique ID of the target group.
    target_group_properties = ionoscloud.TargetGroupProperties() # TargetGroupProperties | The target group properties to be updated.
    try:
        # Partially Modify a Target Group by ID
        api_response = api_instance.targetgroups_patch(target_group_id, target_group_properties)
        print(api_response)
    except ApiException as e:
        print('Exception when calling TargetGroupsApi.targetgroups_patch: %s\n' % e)
```

#### Parameters

| Name                          | Type                                                                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                              | Notes                          |
| ----------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| **target\_group\_id**         | **str**                                                                  | The unique ID of the target group.                                                                                                                                                                                                                                                                                                                                                                                                       |                                |
| **target\_group\_properties** | [**TargetGroupProperties**](/python-sdk/models/targetgroupproperties.md) | The target group properties to be updated.                                                                                                                                                                                                                                                                                                                                                                                               |                                |
| **pretty**                    | **bool**                                                                 | Controls whether the response is pretty-printed (with indentations and new lines).                                                                                                                                                                                                                                                                                                                                                       | \[optional] \[default to True] |
| **depth**                     | **int**                                                                  | Controls the detail depth of the response objects. GET /datacenters/\[ID] - depth=0: Only direct properties are included; children (servers and other elements) are not included. - depth=1: Direct properties and children references are included. - depth=2: Direct properties and children properties are included. - depth=3: Direct properties and children properties and children's children are included. - depth=... and so on | \[optional] \[default to 0]    |
| **x\_contract\_number**       | **int**                                                                  | Users with multiple contracts must provide the contract number, for which all API requests are to be executed.                                                                                                                                                                                                                                                                                                                           | \[optional]                    |

#### Return type

[**TargetGroup**](/python-sdk/models/targetgroup.md)

#### Authorization

Basic Authentication, Token Authentication

#### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## **targetgroups\_post**

> TargetGroup targetgroups\_post(target\_group, pretty=pretty, depth=depth, x\_contract\_number=x\_contract\_number)

Create a Target Group

Creates a target group.

#### Example

```python
from __future__ import print_function
import time
import ionoscloud
from ionoscloud.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/cloudapi/v6
configuration = ionoscloud.Configuration(
    host = 'https://api.ionos.com/cloudapi/v6',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud.TargetGroupsApi(api_client)
    target_group = ionoscloud.TargetGroup() # TargetGroup | The target group to create.
    try:
        # Create a Target Group
        api_response = api_instance.targetgroups_post(target_group)
        print(api_response)
    except ApiException as e:
        print('Exception when calling TargetGroupsApi.targetgroups_post: %s\n' % e)
```

#### Parameters

| Name                    | Type                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                              | Notes                          |
| ----------------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| **target\_group**       | [**TargetGroup**](/python-sdk/models/targetgroup.md) | The target group to create.                                                                                                                                                                                                                                                                                                                                                                                                              |                                |
| **pretty**              | **bool**                                             | Controls whether the response is pretty-printed (with indentations and new lines).                                                                                                                                                                                                                                                                                                                                                       | \[optional] \[default to True] |
| **depth**               | **int**                                              | Controls the detail depth of the response objects. GET /datacenters/\[ID] - depth=0: Only direct properties are included; children (servers and other elements) are not included. - depth=1: Direct properties and children references are included. - depth=2: Direct properties and children properties are included. - depth=3: Direct properties and children properties and children's children are included. - depth=... and so on | \[optional] \[default to 0]    |
| **x\_contract\_number** | **int**                                              | Users with multiple contracts must provide the contract number, for which all API requests are to be executed.                                                                                                                                                                                                                                                                                                                           | \[optional]                    |

#### Return type

[**TargetGroup**](/python-sdk/models/targetgroup.md)

#### Authorization

Basic Authentication, Token Authentication

#### HTTP request headers

* **Content-Type**: application/json
* **Accept**: application/json

## **targetgroups\_put**

> TargetGroup targetgroups\_put(target\_group\_id, target\_group, pretty=pretty, depth=depth, x\_contract\_number=x\_contract\_number)

Modify a Target Group by ID

Modifies the properties of the target group specified by its ID.

#### Example

```python
from __future__ import print_function
import time
import ionoscloud
from ionoscloud.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/cloudapi/v6
configuration = ionoscloud.Configuration(
    host = 'https://api.ionos.com/cloudapi/v6',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud.TargetGroupsApi(api_client)
    target_group_id = 'target_group_id_example' # str | The unique ID of the target group.
    target_group = ionoscloud.TargetGroupPut() # TargetGroupPut | The modified target group.
    try:
        # Modify a Target Group by ID
        api_response = api_instance.targetgroups_put(target_group_id, target_group)
        print(api_response)
    except ApiException as e:
        print('Exception when calling TargetGroupsApi.targetgroups_put: %s\n' % e)
```

#### Parameters

| Name                    | Type                                                       | Description                                                                                                                                                                                                                                                                                                                                                                                                                              | Notes                          |
| ----------------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| **target\_group\_id**   | **str**                                                    | The unique ID of the target group.                                                                                                                                                                                                                                                                                                                                                                                                       |                                |
| **target\_group**       | [**TargetGroupPut**](/python-sdk/models/targetgroupput.md) | The modified target group.                                                                                                                                                                                                                                                                                                                                                                                                               |                                |
| **pretty**              | **bool**                                                   | Controls whether the response is pretty-printed (with indentations and new lines).                                                                                                                                                                                                                                                                                                                                                       | \[optional] \[default to True] |
| **depth**               | **int**                                                    | Controls the detail depth of the response objects. GET /datacenters/\[ID] - depth=0: Only direct properties are included; children (servers and other elements) are not included. - depth=1: Direct properties and children references are included. - depth=2: Direct properties and children properties are included. - depth=3: Direct properties and children properties and children's children are included. - depth=... and so on | \[optional] \[default to 0]    |
| **x\_contract\_number** | **int**                                                    | Users with multiple contracts must provide the contract number, for which all API requests are to be executed.                                                                                                                                                                                                                                                                                                                           | \[optional]                    |

#### Return type

[**TargetGroup**](/python-sdk/models/targetgroup.md)

#### Authorization

Basic Authentication, Token Authentication

#### HTTP request headers

* **Content-Type**: application/json
* **Accept**: application/json


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ionos.com/python-sdk/api/targetgroupsapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
