confluent-kafka-dotnet
Show / Hide Table of Contents

Interface IAdminClient

Defines an Apache Kafka admin client.

Inherited Members
IClient.Handle
IClient.Name
IClient.AddBrokers(string)
IClient.SetSaslCredentials(string, string)
IDisposable.Dispose()
Namespace: Confluent.Kafka
Assembly: Confluent.Kafka.dll
Syntax
public interface IAdminClient : IClient, IDisposable

Methods

AlterConfigsAsync(Dictionary<ConfigResource, List<ConfigEntry>>, AlterConfigsOptions)

Update the configuration for the specified resources. Updates are not transactional so they may succeed for some resources while fail for others. The configs for a particular resource are updated atomically. This operation is supported by brokers with version 0.11.0 or higher. IMPORTANT NOTE: Unspecified configuration properties will be reverted to their default values. Furthermore, if you use DescribeConfigsAsync to obtain the current set of configuration values, modify them, then use AlterConfigsAsync to set them, you will loose any non-default values that are marked as sensitive because they are not provided by DescribeConfigsAsync.

Declaration
Task AlterConfigsAsync(Dictionary<ConfigResource, List<ConfigEntry>> configs, AlterConfigsOptions options = null)
Parameters
Type Name Description
Dictionary<ConfigResource, List<ConfigEntry>> configs

The resources with their configs (topic is the only resource type with configs that can be updated currently).

AlterConfigsOptions options

The options to use when altering configs.

Returns
Type Description
Task

The results of the alter configs requests.

AlterConsumerGroupOffsetsAsync(IEnumerable<ConsumerGroupTopicPartitionOffsets>, AlterConsumerGroupOffsetsOptions)

Alters consumer group offsets for a number of topic partitions.

Declaration
Task<List<AlterConsumerGroupOffsetsResult>> AlterConsumerGroupOffsetsAsync(IEnumerable<ConsumerGroupTopicPartitionOffsets> groupPartitions, AlterConsumerGroupOffsetsOptions options = null)
Parameters
Type Name Description
IEnumerable<ConsumerGroupTopicPartitionOffsets> groupPartitions

A IEnumerable of ConsumerGroupTopicPartitionOffsets, each denoting the group and the TopicPartitionOffsets associated with that group to alter the offsets for. The Count of the IEnumerable must exactly be 1.

AlterConsumerGroupOffsetsOptions options

The options to use when altering consumer group offsets.

Returns
Type Description
Task<List<AlterConsumerGroupOffsetsResult>>

A Task returning a List of AlterConsumerGroupOffsetsResult.

Exceptions
Type Condition
ArgumentException

Thrown if the groupPartitions has a count not equal to 1, or if any of the topic names are null.

AlterConsumerGroupOffsetsException

Thrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

AlterUserScramCredentialsAsync(IEnumerable<UserScramCredentialAlteration>, AlterUserScramCredentialsOptions)

Alter user SASL/SCRAM credentials.

Declaration
Task AlterUserScramCredentialsAsync(IEnumerable<UserScramCredentialAlteration> alterations, AlterUserScramCredentialsOptions options = null)
Parameters
Type Name Description
IEnumerable<UserScramCredentialAlteration> alterations

A IEnumerable with alterations to execute.

AlterUserScramCredentialsOptions options

The options to use when alter user scram credentials.

Returns
Type Description
Task

A Task with an empty result when successful.

Exceptions
Type Condition
ArgumentException

Thrown if any alteration isn't an instance of UserScramCredentialUpsertion or UserScramCredentialDeletion.

AlterUserScramCredentialsException

Thrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

CreateAclsAsync(IEnumerable<AclBinding>, CreateAclsOptions)

Creates one or more ACL bindings.

Declaration
Task CreateAclsAsync(IEnumerable<AclBinding> aclBindings, CreateAclsOptions options = null)
Parameters
Type Name Description
IEnumerable<AclBinding> aclBindings

A IEnumerable with the ACL bindings to create.

CreateAclsOptions options

The options to use when creating the ACL bindings.

Returns
Type Description
Task

A Task with an empty result when successful.

Exceptions
Type Condition
ArgumentNullException

Thrown if aclBindings param is null or a Entry is null or a Pattern is null.

ArgumentException

Thrown if the aclBindings param is empty.

CreateAclsException

Thrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

CreatePartitionsAsync(IEnumerable<PartitionsSpecification>, CreatePartitionsOptions)

Increase the number of partitions for one or more topics as per the supplied PartitionsSpecifications.

Declaration
Task CreatePartitionsAsync(IEnumerable<PartitionsSpecification> partitionsSpecifications, CreatePartitionsOptions options = null)
Parameters
Type Name Description
IEnumerable<PartitionsSpecification> partitionsSpecifications

A collection of PartitionsSpecifications.

CreatePartitionsOptions options

The options to use when creating the partitions.

Returns
Type Description
Task

The results of the PartitionsSpecification requests.

CreateTopicsAsync(IEnumerable<TopicSpecification>, CreateTopicsOptions)

Create a set of new topics.

Declaration
Task CreateTopicsAsync(IEnumerable<TopicSpecification> topics, CreateTopicsOptions options = null)
Parameters
Type Name Description
IEnumerable<TopicSpecification> topics

A collection of specifications for the new topics to create.

CreateTopicsOptions options

The options to use when creating the topics.

Returns
Type Description
Task

The results of the create topic requests.

DeleteAclsAsync(IEnumerable<AclBindingFilter>, DeleteAclsOptions)

Deletes ACL bindings using multiple filters.

Declaration
Task<List<DeleteAclsResult>> DeleteAclsAsync(IEnumerable<AclBindingFilter> aclBindingFilters, DeleteAclsOptions options = null)
Parameters
Type Name Description
IEnumerable<AclBindingFilter> aclBindingFilters

A IEnumerable of ACL binding filters to match ACLs to delete. string attributes match exact values or any string if set to null. enum attributes match exact values or any value if equal to Any. If ResourcePatternType is set to Match deletes ACL bindings with:

  • Literal pattern type with resource name equal to the given resource name
  • Literal pattern type with wildcard resource name that matches the given resource name
  • Prefixed pattern type with resource name that is a prefix of the given resource name
DeleteAclsOptions options

The options to use when describing ACL bindings.

Returns
Type Description
Task<List<DeleteAclsResult>>

A Task returning a List of DeleteAclsResult.

Exceptions
Type Condition
ArgumentNullException

Thrown if aclBindingFilters param is null or any of EntryFilter and PatternFilter is null.

ArgumentException

Thrown if the aclBindingFilters param is empty.

DeleteAclsException

Thrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

DeleteConsumerGroupOffsetsAsync(string, IEnumerable<TopicPartition>, DeleteConsumerGroupOffsetsOptions)

Delete committed offsets for a set of partitions in a consumer group. This will succeed at the partition level only if the group is not actively subscribed to the corresponding topic.

Declaration
Task<DeleteConsumerGroupOffsetsResult> DeleteConsumerGroupOffsetsAsync(string group, IEnumerable<TopicPartition> partitions, DeleteConsumerGroupOffsetsOptions options = null)
Parameters
Type Name Description
string group

Consumer group id

IEnumerable<TopicPartition> partitions

Enumerable of topic partitions to delete committed offsets for.

DeleteConsumerGroupOffsetsOptions options

The options to use when deleting the committed offset.

Returns
Type Description
Task<DeleteConsumerGroupOffsetsResult>

A Task returning DeleteConsumerGroupOffsetsResult.

DeleteGroupsAsync(IList<string>, DeleteGroupsOptions)

Delete a set of groups.

Declaration
Task DeleteGroupsAsync(IList<string> groups, DeleteGroupsOptions options = null)
Parameters
Type Name Description
IList<string> groups

The group names to delete.

DeleteGroupsOptions options

The options to use when deleting groups.

Returns
Type Description
Task

The results of the delete group requests.

DeleteRecordsAsync(IEnumerable<TopicPartitionOffset>, DeleteRecordsOptions)

Delete records (messages) in topic partitions older than the offsets provided.

Declaration
Task<List<DeleteRecordsResult>> DeleteRecordsAsync(IEnumerable<TopicPartitionOffset> topicPartitionOffsets, DeleteRecordsOptions options = null)
Parameters
Type Name Description
IEnumerable<TopicPartitionOffset> topicPartitionOffsets

The offsets to delete up to.

DeleteRecordsOptions options

The options to use when deleting records.

Returns
Type Description
Task<List<DeleteRecordsResult>>

The result of the delete records request.

DeleteTopicsAsync(IEnumerable<string>, DeleteTopicsOptions)

Delete a set of topics. This operation is not transactional so it may succeed for some topics while fail for others. It may take several seconds after the DeleteTopicsResult returns success for all the brokers to become aware that the topics are gone. During this time, topics may continue to be visible via admin operations. If delete.topic.enable is false on the brokers, DeleteTopicsAsync will mark the topics for deletion, but not actually delete them. The Task will return successfully in this case.

Declaration
Task DeleteTopicsAsync(IEnumerable<string> topics, DeleteTopicsOptions options = null)
Parameters
Type Name Description
IEnumerable<string> topics

The topic names to delete.

DeleteTopicsOptions options

The options to use when deleting topics.

Returns
Type Description
Task

The results of the delete topic requests.

DescribeAclsAsync(AclBindingFilter, DescribeAclsOptions)

Finds ACL bindings using a filter.

Declaration
Task<DescribeAclsResult> DescribeAclsAsync(AclBindingFilter aclBindingFilter, DescribeAclsOptions options = null)
Parameters
Type Name Description
AclBindingFilter aclBindingFilter

A filter with attributes that must match. string attributes match exact values or any string if set to null. enum attributes match exact values or any value if equal to Any. If ResourcePatternType is set to Match returns ACL bindings with:

  • Literal pattern type with resource name equal to the given resource name
  • Literal pattern type with wildcard resource name that matches the given resource name
  • Prefixed pattern type with resource name that is a prefix of the given resource name
DescribeAclsOptions options

The options to use when describing ACL bindings.

Returns
Type Description
Task<DescribeAclsResult>

A Task returning a DescribeAclsResult.

Exceptions
Type Condition
ArgumentNullException

Thrown if aclBindingFilter param is null or any of EntryFilter and PatternFilter is null.

DescribeAclsException

Thrown if the corresponding result is in error. The entire result is available via the Result property of the exception.

DescribeConfigsAsync(IEnumerable<ConfigResource>, DescribeConfigsOptions)

Get the configuration for the specified resources. The returned configuration includes default values and the IsDefault property can be used to distinguish them from user supplied values. The value of config entries where IsSensitive is true is always null so that sensitive information is not disclosed. Config entries where IsReadOnly is true cannot be updated. This operation is supported by brokers with version 0.11.0.0 or higher.

Declaration
Task<List<DescribeConfigsResult>> DescribeConfigsAsync(IEnumerable<ConfigResource> resources, DescribeConfigsOptions options = null)
Parameters
Type Name Description
IEnumerable<ConfigResource> resources

The resources (topic and broker resource types are currently supported)

DescribeConfigsOptions options

The options to use when describing configs.

Returns
Type Description
Task<List<DescribeConfigsResult>>

Configs for the specified resources.

DescribeConsumerGroupsAsync(IEnumerable<string>, DescribeConsumerGroupsOptions)

Describes consumer groups in the cluster.

Declaration
Task<DescribeConsumerGroupsResult> DescribeConsumerGroupsAsync(IEnumerable<string> groups, DescribeConsumerGroupsOptions options = null)
Parameters
Type Name Description
IEnumerable<string> groups

The list of groups to describe. This can be set to null to describe all groups.

DescribeConsumerGroupsOptions options

The options to use while describing consumer groups.

Returns
Type Description
Task<DescribeConsumerGroupsResult>

A List of ConsumerGroupDescription.

Exceptions
Type Condition
KafkaException

Thrown if there is any client-level error.

DescribeConsumerGroupsException

Thrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

DescribeUserScramCredentialsAsync(IEnumerable<string>, DescribeUserScramCredentialsOptions)

Describes user SASL/SCRAM credentials.

Declaration
Task<DescribeUserScramCredentialsResult> DescribeUserScramCredentialsAsync(IEnumerable<string> users, DescribeUserScramCredentialsOptions options = null)
Parameters
Type Name Description
IEnumerable<string> users

The list of users to describe for. This can be set to null to describe all users. Individual users cannot be empty strings.

DescribeUserScramCredentialsOptions options

The options to use while describing user scram credentials.

Returns
Type Description
Task<DescribeUserScramCredentialsResult>

A DescribeUserScramCredentialsResult, which contains a List of UserScramCredentialsDescription.

Exceptions
Type Condition
ArgumentException

Thrown if any requested user is a null or empty string.

DescribeUserScramCredentialsException

Thrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

GetMetadata(string, TimeSpan)

Query the cluster for metadata for a specific topic.

[API-SUBJECT-TO-CHANGE] - The API associated with this functionality is subject to change.

Declaration
Metadata GetMetadata(string topic, TimeSpan timeout)
Parameters
Type Name Description
string topic
TimeSpan timeout
Returns
Type Description
Metadata

GetMetadata(TimeSpan)

Query the cluster for metadata.

[API-SUBJECT-TO-CHANGE] - The API associated with this functionality is subject to change.

Declaration
Metadata GetMetadata(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout
Returns
Type Description
Metadata

IncrementalAlterConfigsAsync(Dictionary<ConfigResource, List<ConfigEntry>>, IncrementalAlterConfigsOptions)

Update the configuration for the specified resources. Updates are transactional so if on of them may fail then all the of them will fail. The configs for a particular resource are updated atomically. This operation is supported by brokers with version 2.3.0 or higher. Only specified configuration properties will be updated others will stay same as before, so there is no need to call DescribleConfigsAsync before altering configs. Sensitive non-default values are retained after IncrementalAlterConfigsAsync unlike AlterConfigsAsync.

Declaration
Task<List<IncrementalAlterConfigsResult>> IncrementalAlterConfigsAsync(Dictionary<ConfigResource, List<ConfigEntry>> configs, IncrementalAlterConfigsOptions options = null)
Parameters
Type Name Description
Dictionary<ConfigResource, List<ConfigEntry>> configs

The resources with their configs (topic is the only resource type with configs that can be updated currently).

IncrementalAlterConfigsOptions options

The options to use when altering configs.

Returns
Type Description
Task<List<IncrementalAlterConfigsResult>>

The results of the alter configs requests.

ListConsumerGroupOffsetsAsync(IEnumerable<ConsumerGroupTopicPartitions>, ListConsumerGroupOffsetsOptions)

Lists consumer group offsets for a number of topic partitions.

Declaration
Task<List<ListConsumerGroupOffsetsResult>> ListConsumerGroupOffsetsAsync(IEnumerable<ConsumerGroupTopicPartitions> groupPartitions, ListConsumerGroupOffsetsOptions options = null)
Parameters
Type Name Description
IEnumerable<ConsumerGroupTopicPartitions> groupPartitions

A IEnumerable of ConsumerGroupTopicPartitions, each denoting the group and the TopicPartitions associated with that group to fetch the offsets for. The Count of the IEnumerable must exactly be 1.

ListConsumerGroupOffsetsOptions options

The options to use when listing consumer group offsets.

Returns
Type Description
Task<List<ListConsumerGroupOffsetsResult>>

A Task returning a List of ListConsumerGroupOffsetsResult.

Exceptions
Type Condition
ArgumentException

Thrown if the groupPartitions has a count not equal to 1, or if any of the topic names are null.

ListConsumerGroupOffsetsException

Thrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

ListConsumerGroupsAsync(ListConsumerGroupsOptions)

Lists consumer groups in the cluster.

Declaration
Task<ListConsumerGroupsResult> ListConsumerGroupsAsync(ListConsumerGroupsOptions options = null)
Parameters
Type Name Description
ListConsumerGroupsOptions options

The options to use while listing consumer groups.

Returns
Type Description
Task<ListConsumerGroupsResult>

A ListConsumerGroupsResult, which contains a List of ConsumerGroupListing.

Exceptions
Type Condition
KafkaException

Thrown if there is any client-level error.

ListConsumerGroupsException

Thrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

ListGroup(string, TimeSpan)

DEPRECATED. Superseded by ListConsumerGroups and DescribeConsumerGroups. Get information pertaining to a particular group in the Kafka cluster (blocking).

[API-SUBJECT-TO-CHANGE] - The API associated with this functionality is subject to change.

Declaration
GroupInfo ListGroup(string group, TimeSpan timeout)
Parameters
Type Name Description
string group

The group of interest.

TimeSpan timeout

The maximum period of time the call may block.

Returns
Type Description
GroupInfo

Returns information pertaining to the specified group or null if this group does not exist.

ListGroups(TimeSpan)

DEPRECATED. Superseded by ListConsumerGroups and DescribeConsumerGroups. Get information pertaining to all groups in the Kafka cluster (blocking)

[API-SUBJECT-TO-CHANGE] - The API associated with this functionality is subject to change.

Declaration
List<GroupInfo> ListGroups(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout

The maximum period of time the call may block.

Returns
Type Description
List<GroupInfo>

Extension Methods

IAdminClientExtensions.DescribeClusterAsync(IAdminClient, DescribeClusterOptions)
IAdminClientExtensions.DescribeTopicsAsync(IAdminClient, TopicCollection, DescribeTopicsOptions)
IAdminClientExtensions.ElectLeadersAsync(IAdminClient, ElectionType, IEnumerable<TopicPartition>, ElectLeadersOptions)
IAdminClientExtensions.ListOffsetsAsync(IAdminClient, IEnumerable<TopicPartitionOffsetSpec>, ListOffsetsOptions)
ClientExtensions.OAuthBearerSetToken(IClient, string, long, string, IDictionary<string, string>)
ClientExtensions.OAuthBearerSetTokenFailure(IClient, string)
In this article