# Public Cloud › Analytics › Kafka › Topics API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Public Cloud product's sections: https://developers.eu.ovhcloud.com/reference/public-cloud/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 6 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/public-cloud/analytics/kafka/topics/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/public-cloud/analytics/kafka/topics.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/public-cloud/analytics/kafka/topics.json?format=openapi3

## Operations

- `GET /publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic` — List topics
- `GET /publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}` — Get a topic
- `POST /publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic` — Create a topic
- `DELETE /publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}` — Delete a topic
- `PUT /publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}` — Update a topic
- `PATCH /publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}` — Partially update a topic

## List topics

`GET /v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/analytics/kafka/topics/#get-publiccloud-project-projectid-managedanalytics-kafka-serviceid-topic

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:analytics/kafka/topic/get`

Returns the topics of the service with their partitions, replication and retention settings.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Pagination-Cursor` | header | string |  | Pagination cursor |
| `X-Pagination-Size` | header | integer |  | Pagination size |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.kafka.Topic[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the resource was created |
| `id` | string (uuid) | read-only | Unique identifier of the topic |
| `minimumInSyncReplicas` | integer | read-only | Minimum number of in-sync replicas required before a write is acknowledged |
| `name` | string | read-only | Name of the Kafka topic |
| `partitions` | integer | read-only | Number of partitions for this topic |
| `replication` | integer | read-only | Replication factor for this topic |
| `retentionBytes` | integer | read-only | Maximum size in bytes retained per partition. -1 means unlimited. |
| `retentionHours` | integer | read-only | Maximum time in hours that messages are retained. -1 means unlimited. |
| `updatedAt` | string (date-time) | read-only | Date of the last update to the resource |

```json
[
  {
    "checksum": "string",
    "createdAt": "2024-01-01T12:00:00Z",
    "id": "00000000-0000-0000-0000-000000000000",
    "minimumInSyncReplicas": 0,
    "name": "string",
    "partitions": 0,
    "replication": 0,
    "retentionBytes": 0,
    "retentionHours": 0,
    "updatedAt": "2024-01-01T12:00:00Z"
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic");

print_r($result);
?>
```

## Get a topic

`GET /v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/analytics/kafka/topics/#get-publiccloud-project-projectid-managedanalytics-kafka-serviceid-topic-topicid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:analytics/kafka/topic/get`

Returns the partitions, replication factor, minimum in-sync replicas and retention settings of the topic.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `topicId` | path | string (uuid) | yes | Topic ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.kafka.Topic | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the resource was created |
| `id` | string (uuid) | read-only | Unique identifier of the topic |
| `minimumInSyncReplicas` | integer | read-only | Minimum number of in-sync replicas required before a write is acknowledged |
| `name` | string | read-only | Name of the Kafka topic |
| `partitions` | integer | read-only | Number of partitions for this topic |
| `replication` | integer | read-only | Replication factor for this topic |
| `retentionBytes` | integer | read-only | Maximum size in bytes retained per partition. -1 means unlimited. |
| `retentionHours` | integer | read-only | Maximum time in hours that messages are retained. -1 means unlimited. |
| `updatedAt` | string (date-time) | read-only | Date of the last update to the resource |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "minimumInSyncReplicas": 0,
  "name": "string",
  "partitions": 0,
  "replication": 0,
  "retentionBytes": 0,
  "retentionHours": 0,
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}");

print_r($result);
?>
```

## Create a topic

`POST /v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/analytics/kafka/topics/#post-publiccloud-project-projectid-managedanalytics-kafka-serviceid-topic

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:analytics/kafka/topic/create`

Creates a topic. By default it has 1 partition, a replication factor of 1 and a retention of 168 hours (7 days). The replication factor must not exceed the number of brokers.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |

### Request body (required)

Type: `publicCloud.database.kafka.TopicCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `minimumInSyncReplicas` | integer |  | Minimum number of in-sync replicas. Defaults to 1 when null. |
| `name` | string | yes | Name of the Kafka topic |
| `partitions` | integer |  | Number of partitions. Defaults to 1 when null. |
| `replication` | integer |  | Replication factor. Must not exceed the number of brokers. Defaults to 1 when null. |
| `retentionBytes` | integer |  | Maximum size in bytes retained per partition. -1 means unlimited. Defaults to -1 when null. |
| `retentionHours` | integer |  | Maximum time in hours that messages are retained. -1 means unlimited. Defaults to 168 (7 days) when null. |

```json
{
  "minimumInSyncReplicas": 0,
  "name": "string",
  "partitions": 0,
  "replication": 0,
  "retentionBytes": 0,
  "retentionHours": 0
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.kafka.Topic | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the resource was created |
| `id` | string (uuid) | read-only | Unique identifier of the topic |
| `minimumInSyncReplicas` | integer | read-only | Minimum number of in-sync replicas required before a write is acknowledged |
| `name` | string | read-only | Name of the Kafka topic |
| `partitions` | integer | read-only | Number of partitions for this topic |
| `replication` | integer | read-only | Replication factor for this topic |
| `retentionBytes` | integer | read-only | Maximum size in bytes retained per partition. -1 means unlimited. |
| `retentionHours` | integer | read-only | Maximum time in hours that messages are retained. -1 means unlimited. |
| `updatedAt` | string (date-time) | read-only | Date of the last update to the resource |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "minimumInSyncReplicas": 0,
  "name": "string",
  "partitions": 0,
  "replication": 0,
  "retentionBytes": 0,
  "retentionHours": 0,
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.database.kafka.TopicCreation
result = client.post("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic",
	minimumInSyncReplicas = None, # Minimum number of in-sync replicas. Defaults to 1 when null. (type: integer, nullable)
	name = None, # Name of the Kafka topic (type: string)
	partitions = None, # Number of partitions. Defaults to 1 when null. (type: integer, nullable)
	replication = None, # Replication factor. Must not exceed the number of brokers. Defaults to 1 when null. (type: integer, nullable)
	retentionBytes = None, # Maximum size in bytes retained per partition. -1 means unlimited. Defaults to -1 when null. (type: integer, nullable)
	retentionHours = None, # Maximum time in hours that messages are retained. -1 means unlimited. Defaults to 168 (7 days) when null. (type: integer, nullable)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.database.kafka.TopicCreation
$result = $ovh->post("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic", array(
	minimumInSyncReplicas => null, // Minimum number of in-sync replicas. Defaults to 1 when null. (type: integer, nullable)
	name => null, // Name of the Kafka topic (type: string)
	partitions => null, // Number of partitions. Defaults to 1 when null. (type: integer, nullable)
	replication => null, // Replication factor. Must not exceed the number of brokers. Defaults to 1 when null. (type: integer, nullable)
	retentionBytes => null, // Maximum size in bytes retained per partition. -1 means unlimited. Defaults to -1 when null. (type: integer, nullable)
	retentionHours => null, // Maximum time in hours that messages are retained. -1 means unlimited. Defaults to 168 (7 days) when null. (type: integer, nullable)
));

print_r($result);
?>
```

## Delete a topic

`DELETE /v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/analytics/kafka/topics/#delete-publiccloud-project-projectid-managedanalytics-kafka-serviceid-topic-topicid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:analytics/kafka/topic/delete`

Permanently deletes the topic and its messages.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `topicId` | path | string (uuid) | yes | Topic ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.kafka.Topic | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the resource was created |
| `id` | string (uuid) | read-only | Unique identifier of the topic |
| `minimumInSyncReplicas` | integer | read-only | Minimum number of in-sync replicas required before a write is acknowledged |
| `name` | string | read-only | Name of the Kafka topic |
| `partitions` | integer | read-only | Number of partitions for this topic |
| `replication` | integer | read-only | Replication factor for this topic |
| `retentionBytes` | integer | read-only | Maximum size in bytes retained per partition. -1 means unlimited. |
| `retentionHours` | integer | read-only | Maximum time in hours that messages are retained. -1 means unlimited. |
| `updatedAt` | string (date-time) | read-only | Date of the last update to the resource |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "minimumInSyncReplicas": 0,
  "name": "string",
  "partitions": 0,
  "replication": 0,
  "retentionBytes": 0,
  "retentionHours": 0,
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}");

print_r($result);
?>
```

## Update a topic

`PUT /v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/analytics/kafka/topics/#put-publiccloud-project-projectid-managedanalytics-kafka-serviceid-topic-topicid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:analytics/kafka/topic/edit`

Updates the partitions, replication, minimum in-sync replicas and retention of the topic. Every field is required. The number of partitions can only be increased.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `topicId` | path | string (uuid) | yes | Topic ID |

### Request body (required)

Type: `publicCloud.database.kafka.TopicReplace`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `minimumInSyncReplicas` | integer | yes | Minimum number of in-sync replicas required before a write is acknowledged |
| `partitions` | integer | yes | New number of partitions. Can only be increased, never decreased. |
| `replication` | integer | yes | New replication factor. Must not exceed the number of brokers. |
| `retentionBytes` | integer | yes | Maximum size in bytes retained per partition. -1 means unlimited. |
| `retentionHours` | integer | yes | Maximum time in hours that messages are retained. -1 means unlimited. |

```json
{
  "minimumInSyncReplicas": 0,
  "partitions": 0,
  "replication": 0,
  "retentionBytes": 0,
  "retentionHours": 0
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.kafka.Topic | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the resource was created |
| `id` | string (uuid) | read-only | Unique identifier of the topic |
| `minimumInSyncReplicas` | integer | read-only | Minimum number of in-sync replicas required before a write is acknowledged |
| `name` | string | read-only | Name of the Kafka topic |
| `partitions` | integer | read-only | Number of partitions for this topic |
| `replication` | integer | read-only | Replication factor for this topic |
| `retentionBytes` | integer | read-only | Maximum size in bytes retained per partition. -1 means unlimited. |
| `retentionHours` | integer | read-only | Maximum time in hours that messages are retained. -1 means unlimited. |
| `updatedAt` | string (date-time) | read-only | Date of the last update to the resource |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "minimumInSyncReplicas": 0,
  "name": "string",
  "partitions": 0,
  "replication": 0,
  "retentionBytes": 0,
  "retentionHours": 0,
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.database.kafka.TopicReplace
result = client.put("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}",
	minimumInSyncReplicas = None, # Minimum number of in-sync replicas required before a write is acknowledged (type: integer)
	partitions = None, # New number of partitions. Can only be increased, never decreased. (type: integer)
	replication = None, # New replication factor. Must not exceed the number of brokers. (type: integer)
	retentionBytes = None, # Maximum size in bytes retained per partition. -1 means unlimited. (type: integer)
	retentionHours = None, # Maximum time in hours that messages are retained. -1 means unlimited. (type: integer)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.database.kafka.TopicReplace
$result = $ovh->put("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}", array(
	minimumInSyncReplicas => null, // Minimum number of in-sync replicas required before a write is acknowledged (type: integer)
	partitions => null, // New number of partitions. Can only be increased, never decreased. (type: integer)
	replication => null, // New replication factor. Must not exceed the number of brokers. (type: integer)
	retentionBytes => null, // Maximum size in bytes retained per partition. -1 means unlimited. (type: integer)
	retentionHours => null, // Maximum time in hours that messages are retained. -1 means unlimited. (type: integer)
));

print_r($result);
?>
```

## Partially update a topic

`PATCH /v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/analytics/kafka/topics/#patch-publiccloud-project-projectid-managedanalytics-kafka-serviceid-topic-topicid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:analytics/kafka/topic/edit`

Partially updates the partitions, replication, minimum in-sync replicas or retention of the topic. The number of partitions can only be increased.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `topicId` | path | string (uuid) | yes | Topic ID |

### Request body (required)

Type: `publicCloud.database.kafka.TopicUpdate`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `minimumInSyncReplicas` | integer |  | Minimum number of in-sync replicas required before a write is acknowledged |
| `partitions` | integer |  | New number of partitions. Can only be increased, never decreased. |
| `replication` | integer |  | New replication factor. Must not exceed the number of brokers. |
| `retentionBytes` | integer |  | Maximum size in bytes retained per partition. -1 means unlimited. |
| `retentionHours` | integer |  | Maximum time in hours that messages are retained. -1 means unlimited. |

```json
{
  "minimumInSyncReplicas": 0,
  "partitions": 0,
  "replication": 0,
  "retentionBytes": 0,
  "retentionHours": 0
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.kafka.Topic | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the resource was created |
| `id` | string (uuid) | read-only | Unique identifier of the topic |
| `minimumInSyncReplicas` | integer | read-only | Minimum number of in-sync replicas required before a write is acknowledged |
| `name` | string | read-only | Name of the Kafka topic |
| `partitions` | integer | read-only | Number of partitions for this topic |
| `replication` | integer | read-only | Replication factor for this topic |
| `retentionBytes` | integer | read-only | Maximum size in bytes retained per partition. -1 means unlimited. |
| `retentionHours` | integer | read-only | Maximum time in hours that messages are retained. -1 means unlimited. |
| `updatedAt` | string (date-time) | read-only | Date of the last update to the resource |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "minimumInSyncReplicas": 0,
  "name": "string",
  "partitions": 0,
  "replication": 0,
  "retentionBytes": 0,
  "retentionHours": 0,
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X PATCH \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.database.kafka.TopicUpdate
result = client.patch("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}",
	minimumInSyncReplicas = None, # Minimum number of in-sync replicas required before a write is acknowledged (type: integer, nullable)
	partitions = None, # New number of partitions. Can only be increased, never decreased. (type: integer, nullable)
	replication = None, # New replication factor. Must not exceed the number of brokers. (type: integer, nullable)
	retentionBytes = None, # Maximum size in bytes retained per partition. -1 means unlimited. (type: integer, nullable)
	retentionHours = None, # Maximum time in hours that messages are retained. -1 means unlimited. (type: integer, nullable)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.database.kafka.TopicUpdate
$result = $ovh->patch("/v2/publicCloud/project/{projectId}/managedAnalytics/kafka/{serviceId}/topic/{topicId}", array(
	minimumInSyncReplicas => null, // Minimum number of in-sync replicas required before a write is acknowledged (type: integer, nullable)
	partitions => null, // New number of partitions. Can only be increased, never decreased. (type: integer, nullable)
	replication => null, // New replication factor. Must not exceed the number of brokers. (type: integer, nullable)
	retentionBytes => null, // Maximum size in bytes retained per partition. -1 means unlimited. (type: integer, nullable)
	retentionHours => null, // Maximum time in hours that messages are retained. -1 means unlimited. (type: integer, nullable)
));

print_r($result);
?>
```
