{"modulePath":"github.com/segmentio/topicctl","version":"v1.23.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package admin\n\n## Constants\n\n```go\nconst (\n\t// RetentionKey is the config key used for topic time retention.\n\tRetentionKey = \"retention.ms\"\n\n\t// LeaderThrottledKey is the config key for the leader throttle rate.\n\tLeaderThrottledKey = \"leader.replication.throttled.rate\"\n\n\t// FollowerThrottledKey is the config key for the follower throttle rate.\n\tFollowerThrottledKey = \"follower.replication.throttled.rate\"\n\n\t// LeaderReplicasThrottledKey is the config key for the list of leader replicas\n\t// that should be throttled.\n\tLeaderReplicasThrottledKey = \"leader.replication.throttled.replicas\"\n\n\t// FollowerReplicasThrottledKey is the config key for the list of follower replicas\n\t// that should be throttled.\n\tFollowerReplicasThrottledKey = \"follower.replication.throttled.replicas\"\n)\n```\n\n```go\nconst (\n\tListenerNotFoundError kafka.Error = 72\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// ErrTopicDoesNotExist is returned by admin functions when a topic that should exist\n\t// does not.\n\tErrTopicDoesNotExist = errors.New(\"Topic does not exist\")\n)\n```\n\n## Functions\n\n```go\nfunc AssignmentsToReplicas(assignments []PartitionAssignment) ([][]int, error)\n```\nAssignmentsToReplicas is the inverse of ReplicasToAssignments. Used for unit tests.\n\n```go\nfunc BrokerCountsPerRack(brokers []BrokerInfo) map[string]int\n```\nBrokerCountsPerRack returns a mapping of rack -\u003e number of brokers.\n\n```go\nfunc BrokerIDs(brokers []BrokerInfo) []int\n```\nBrokerIDs returns a slice of the IDs of the argument brokers.\n\n```go\nfunc BrokerRacks(brokers []BrokerInfo) map[int]string\n```\nBrokerRacks returns a mapping of broker ID -\u003e rack.\n\n```go\nfunc BrokersPerRack(brokers []BrokerInfo) map[string][]int\n```\nBrokersPerRack returns a mapping of rack -\u003e broker IDs.\n\n```go\nfunc CheckAssignments(assignments []PartitionAssignment) error\n```\nCheckAssignments does some basic sanity checks on the assignments that are passed into an Assigner or extender so that we can fail early if something is obviously wrong.\n\n```go\nfunc DistinctRacks(brokers []BrokerInfo) []string\n```\nDistinctRacks returns a sorted slice of all the distinct racks in the cluster.\n\n```go\nfunc FormatACLInfo(a ACLInfo) string\n```\nFormatACLInfo formats an ACLInfo struct as a string, using the string version of all the fields.\n\n```go\nfunc FormatACLs(acls []ACLInfo) string\n```\nFormatACLs creates a pretty table that lists the details of the argument acls.\n\n```go\nfunc FormatAssignentDiffs(\n\tcurr []PartitionAssignment,\n\tdesired []PartitionAssignment,\n\tbrokers []BrokerInfo,\n) string\n```\nFormatAssignentDiffs generates a pretty table that shows the before and after states of a partition replica and/or leader update.\n\n```go\nfunc FormatBrokerMaxPartitions(\n\tcurr []PartitionAssignment,\n\tdesired []PartitionAssignment,\n\tbrokers []BrokerInfo,\n) string\n```\nFormatBrokerMaxPartitions generates a pretty table that shows the total number of partitions that each broker is involved in for a diff. It's used to evaluate the potential extra load that could occur on brokers during a migration.\n\n```go\nfunc FormatBrokerRackReplicas(brokers []BrokerInfo, topics []TopicInfo) string\n```\nFormatBrokerRackReplicas creates a pretty table that shows how many replicas are in each position (i.e., leader, second, third) by rack across all topics. Useful for showing total-topic balance.\n\n```go\nfunc FormatBrokerReplicas(brokers []BrokerInfo, topics []TopicInfo) string\n```\nFormatBrokerReplicas creates a pretty table that shows how many replicas are in each position (i.e., leader, second, third) by broker across all topics. Useful for showing total-topic balance.\n\n```go\nfunc FormatBrokers(brokers []BrokerInfo, full bool) string\n```\nFormatBrokers creates a pretty table from a list of brokers.\n\n```go\nfunc FormatBrokersPerRack(brokers []BrokerInfo) string\n```\nFormatBrokersPerRack creates a pretty table that shows the number of brokers per rack.\n\n```go\nfunc FormatClusterID(clusterID string) string\n```\nFormatClusterID creates a pretty table for cluster ID.\n\n```go\nfunc FormatConfig(configMap map[string]string) string\n```\nFormatConfig creates a pretty table with all of the keys and values in a topic or broker config.\n\n```go\nfunc FormatControllerID(brokerID int) string\n```\nFormatControllerID creates a pretty table for controller broker.\n\n```go\nfunc FormatTopicLeadersPerRack(topic TopicInfo, brokers []BrokerInfo) string\n```\nFormatTopicLeadersPerRack creates a pretty table that shows the number of partitions with a leader in each rack.\n\n```go\nfunc FormatTopicPartitions(partitions []PartitionInfo, brokers []BrokerInfo) string\n```\nFormatTopicPartitions creates a pretty table with information on all of the partitions for a topic.\n\n```go\nfunc FormatTopics(topics []TopicInfo, brokers []BrokerInfo, full bool) string\n```\nFormatTopics creates a pretty table that lists the details of the argument topics.\n\n```go\nfunc FormatTopicsPartitions(\n\ttopicsPartitionsStatusInfo map[string][]PartitionStatusInfo,\n\tbrokers []BrokerInfo,\n) string\n```\nFormatTopicsPartitions creates a pretty table with information on all of the partitions for topics.\n\n```go\nfunc FormatTopicsPartitionsSummary(\n\ttopicsPartitionsStatusSummary map[string]map[PartitionStatus][]int,\n) string\n```\nFormatTopicsPartitionsSummary creates a pretty table with summary of the partitions for topics.\n\n```go\nfunc FormatUsers(users []UserInfo) string\n```\nFormatUsers creates a pretty table that lists the details of the argument users.\n\n```go\nfunc GetAllTopicNamesFromMetadata(\n\tmetadata *kafka.MetadataResponse,\n) map[string]bool\n```\n\n```go\nfunc GetKafkaCredentials(ctx context.Context, svc *secretsmanager.Client, secretArn string) (credentials, error)\n```\n\n```go\nfunc GetTopicsPartitionsStatusInfo(\n\tmetadata *kafka.MetadataResponse,\n\ttopics []string,\n\tstatus PartitionStatus,\n) map[string][]PartitionStatusInfo\n```\nGet the partition status info for specified topics\n\n```go\nfunc GetTopicsPartitionsStatusSummary(\n\tmetadata *kafka.MetadataResponse,\n\ttopics []string,\n\tstatus PartitionStatus,\n) (map[string]map[PartitionStatus][]int, int, int, int)\n```\nGet the partition status summary\n\n```go\nfunc GetValidTopicNamesFromMetadata(\n\ttopics []string,\n\tmetadata *kafka.MetadataResponse,\n) map[string]bool\n```\ngiven an input of topics, returns topics that exist in the cluster\n\n```go\nfunc HasLeaders(topics []TopicInfo) bool\n```\nHasLeaders returns whether at least one partition in the argument topics has a non-zero leader set. Used for formatting purposes.\n\n```go\nfunc LeadersPerRack(brokers []BrokerInfo, topic TopicInfo) map[string]int\n```\nLeadersPerRack returns a mapping of rack -\u003e number of partitions with a leader in that rack.\n\n```go\nfunc MaxPartitionsPerBroker(\n\tallAssignments ...[]PartitionAssignment,\n) map[int]int\n```\nMaxPartitionsPerBroker calculates the number of partitions that each broker may need to handle during a migration.\n\n```go\nfunc MaxReplication(topics []TopicInfo) int\n```\nMaxReplication returns the maximum amount of replication across all partitions in the argument topics.\n\n```go\nfunc NewLeaderPartitions(\n\tcurrent []PartitionAssignment,\n\tdesired []PartitionAssignment) []int\n```\nNewLeaderPartitions returns the partition IDs which will have new leaders given the current and desired assignments.\n\n```go\nfunc ParseBrokerThrottles(brokers []BrokerInfo) (\n\t[]BrokerThrottle,\n\t[]BrokerThrottle,\n\terror,\n)\n```\nParseBrokerThrottles returns slices of the leader and follower throttles for the argument brokers.\n\n```go\nfunc ParsePartitionThrottles(topic TopicInfo) (\n\t[]PartitionThrottle,\n\t[]PartitionThrottle,\n\terror,\n)\n```\nParsePartitionThrottles returns slices of the leader and follower partition throttles for the argument topic.\n\n```go\nfunc PartitionIDs(partitions []PartitionInfo) []int\n```\nPartitionIDs returns the IDs from the argument partitions.\n\n```go\nfunc PartitionThrottleConfigEntries(\n\tleaderThrottles []PartitionThrottle,\n\tfollowerThrottles []PartitionThrottle,\n) []kafka.ConfigEntry\n```\nPartitionThrottleConfigEntries generates the topic config entries for the provided leader and follower throttles.\n\n```go\nfunc SameBrokers(\n\ta PartitionAssignment,\n\tb PartitionAssignment,\n) bool\n```\nSameBrokers returns whether two PartitionAssignments have the same brokers.\n\n```go\nfunc ThrottledBrokerIDs(brokers []BrokerInfo) []int\n```\nThrottledBrokerIDs returns a slice of the IDs of the subset of argument brokers that have throttles on them.\n\n```go\nfunc ThrottledTopicNames(topics []TopicInfo) []string\n```\nThrottledTopicNames returns the names of topics in the argument slice that have throttles on them.\n\n## Types\n\n```go\ntype ACLInfo struct {\n\tResourceType   ResourceType      `json:\"resourceType\"`\n\tResourceName   string            `json:\"resourceName\"`\n\tPatternType    PatternType       `json:\"patternType\"`\n\tPrincipal      string            `json:\"principal\"`\n\tHost           string            `json:\"host\"`\n\tOperation      ACLOperationType  `json:\"operation\"`\n\tPermissionType ACLPermissionType `json:\"permissionType\"`\n}\n```\nPartitionInfo represents the information stored about an ACL in zookeeper.\n\n```go\ntype ACLOperationType kafka.ACLOperationType\n```\nACLOperationType presents the Kafka operation type. We need to subtype this to be able to define methods to satisfy the Value interface from Cobra so we can use it as a Cobra flag.\n\n```go\nfunc (o *ACLOperationType) Set(v string) error\n```\nSet is used by Cobra to set the value of a variable from a Cobra flag.\n\n```go\nfunc (o *ACLOperationType) String() string\n```\nString is used both by fmt.Print and by Cobra in help text.\n\n```go\nfunc (o *ACLOperationType) Type() string\n```\nType is used by Cobra in help text.\n\n```go\ntype ACLPermissionType kafka.ACLPermissionType\n```\nACLPermissionType presents the Kafka operation type. We need to subtype this to be able to define methods to satisfy the Value interface from Cobra so we can use it as a Cobra flag.\n\n```go\nfunc (p *ACLPermissionType) Set(v string) error\n```\nSet is used by Cobra to set the value of a variable from a Cobra flag.\n\n```go\nfunc (p *ACLPermissionType) String() string\n```\nString is used both by fmt.Print and by Cobra in help text.\n\n```go\nfunc (p *ACLPermissionType) Type() string\n```\nType is used by Cobra in help text.\n\n```go\ntype AssignmentDiff struct {\n\tPartitionID int\n\tOld         PartitionAssignment\n\tNew         PartitionAssignment\n}\n```\nAssignmentDiff represents the diff in a single partition reassignment.\n\n```go\nfunc AssignmentDiffs(\n\tcurrent []PartitionAssignment,\n\tdesired []PartitionAssignment,\n) []AssignmentDiff\n```\nAssignmentDiffs returns the diffs implied by the argument current and desired PartitionAssignments. Used for displaying diffs to user.\n\n```go\ntype BrokerAdminClient struct {\n\t// contains filtered or unexported fields\n}\n```\nBrokerAdminClient is a Client implementation that only uses broker APIs, without any zookeeper access.\n\n```go\nfunc NewBrokerAdminClient(\n\tctx context.Context,\n\tconfig BrokerAdminClientConfig,\n) (*BrokerAdminClient, error)\n```\nNewBrokerAdminClient constructs a new BrokerAdminClient instance.\n\n```go\nfunc (c *BrokerAdminClient) AcquireLock(ctx context.Context, path string) (\n\tzk.Lock,\n\terror,\n)\n```\nAcquireLock acquires a lock that can be used to prevent simultaneous changes to a topic. NOTE: Not implemented for broker-based clients.\n\n```go\nfunc (c *BrokerAdminClient) AddPartitions(\n\tctx context.Context,\n\ttopic string,\n\tnewAssignments []PartitionAssignment,\n) error\n```\nAddPartitions extends a topic by adding one or more new partitions to it.\n\n```go\nfunc (c *BrokerAdminClient) AssignPartitions(\n\tctx context.Context,\n\ttopic string,\n\tassignments []PartitionAssignment,\n) error\n```\nAssignPartitions sets the replica broker IDs for one or more partitions in a topic.\n\n```go\nfunc (c *BrokerAdminClient) Close() error\n```\nClose closes the client.\n\n```go\nfunc (c *BrokerAdminClient) CreateACLs(\n\tctx context.Context,\n\tacls []kafka.ACLEntry,\n) error\n```\nCreateACLs creates ACLs in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) CreateTopic(\n\tctx context.Context,\n\tconfig kafka.TopicConfig,\n) error\n```\nCreateTopic creates a topic in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) DeleteACLs(\n\tctx context.Context,\n\tfilters []kafka.DeleteACLsFilter,\n) (*kafka.DeleteACLsResponse, error)\n```\nDeleteACLs deletes ACLs in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) DeleteTopic(ctx context.Context, topic string) error\n```\nDeleteTopic deletes a topic in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetACLs(\n\tctx context.Context,\n\tfilter kafka.ACLFilter,\n) ([]ACLInfo, error)\n```\nGetACLs gets full information about each ACL in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetAllTopicsMetadata(\n\tctx context.Context,\n) (*kafka.MetadataResponse, error)\n```\n\n```go\nfunc (c *BrokerAdminClient) GetBrokerIDs(ctx context.Context) ([]int, error)\n```\nGetBrokerIDs get the IDs of all brokers in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetBrokers(ctx context.Context, ids []int) (\n\t[]BrokerInfo,\n\terror,\n)\n```\nGetBrokers gets information about all brokers in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetClusterID(ctx context.Context) (string, error)\n```\nGetClusterID gets the ID of the cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetConnector() *Connector\n```\nGetConnector gets the Connector instance for this cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetControllerID(ctx context.Context) (\n\tint,\n\terror,\n)\n```\nGetControllerID gets ID of the active controller broker\n\n```go\nfunc (c *BrokerAdminClient) GetSupportedFeatures() SupportedFeatures\n```\nGetSupportedFeatures gets the features supported by the cluster for this client.\n\n```go\nfunc (c *BrokerAdminClient) GetTopic(\n\tctx context.Context,\n\tname string,\n\tdetailed bool,\n) (TopicInfo, error)\n```\nGetTopic gets the details of a single topic in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetTopicNames(ctx context.Context) ([]string, error)\n```\nGetTopicNames gets just the names of each topic in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetTopics(\n\tctx context.Context,\n\tnames []string,\n\tdetailed bool,\n) ([]TopicInfo, error)\n```\nGetTopics gets full information about each topic in the cluster.\n\n```go\nfunc (c *BrokerAdminClient) GetUsers(\n\tctx context.Context,\n\tnames []string,\n) ([]UserInfo, error)\n```\n\n```go\nfunc (c *BrokerAdminClient) LockHeld(ctx context.Context, path string) (bool, error)\n```\nLockHeld returns whether a lock is currently held for the given path. NOTE: Not implemented for broker-based clients.\n\n```go\nfunc (c *BrokerAdminClient) RunLeaderElection(\n\tctx context.Context,\n\ttopic string,\n\tpartitions []int,\n) error\n```\nRunLeaderElection triggers a leader election for one or more partitions in a topic.\n\n```go\nfunc (c *BrokerAdminClient) UpdateBrokerConfig(\n\tctx context.Context,\n\tid int,\n\tconfigEntries []kafka.ConfigEntry,\n\toverwrite bool,\n) ([]string, error)\n```\nUpdateBrokerConfig updates the configuration for the argument broker.  It returns the config keys that were updated.\n\n```go\nfunc (c *BrokerAdminClient) UpdateTopicConfig(\n\tctx context.Context,\n\tname string,\n\tconfigEntries []kafka.ConfigEntry,\n\toverwrite bool,\n) ([]string, error)\n```\nUpdateTopicConfig updates the configuration for the argument topic. It returns the config keys that were updated.\n\n```go\nfunc (c *BrokerAdminClient) UpsertUser(\n\tctx context.Context,\n\tuser kafka.UserScramCredentialsUpsertion,\n) error\n```\n\n```go\ntype BrokerAdminClientConfig struct {\n\tConnectorConfig\n\tReadOnly          bool\n\tExpectedClusterID string\n}\n```\nBrokerAdminClientConfig contains the configuration settings to construct a BrokerAdminClient instance.\n\n```go\ntype BrokerInfo struct {\n\tID               int               `json:\"id\"`\n\tEndpoints        []string          `json:\"endpoints\"`\n\tHost             string            `json:\"host\"`\n\tPort             int32             `json:\"port\"`\n\tInstanceID       string            `json:\"instanceID\"`\n\tAvailabilityZone string            `json:\"availabilityZone\"`\n\tRack             string            `json:\"rack\"`\n\tInstanceType     string            `json:\"instanceType\"`\n\tVersion          int               `json:\"version\"`\n\tTimestamp        time.Time         `json:\"timestamp\"`\n\tConfig           map[string]string `json:\"config\"`\n}\n```\nBrokerInfo represents the information stored about a broker in zookeeper.\n\n```go\nfunc (b BrokerInfo) Addr() string\n```\nAddr returns the address of the current BrokerInfo.\n\n```go\nfunc (b BrokerInfo) IsThrottled() bool\n```\nIsThrottled determines whether the broker has any throttles in its config.\n\n```go\ntype BrokerThrottle struct {\n\tBroker        int\n\tThrottleBytes int64\n}\n```\nBrokerThrottle represents a throttle being applied to a single broker.\n\n```go\nfunc BrokerThrottles(\n\tleaderThrottles []PartitionThrottle,\n\tfollowerThrottles []PartitionThrottle,\n\tthrottleBytes int64,\n) []BrokerThrottle\n```\nBrokerThrottles returns a slice of BrokerThrottles that we should apply. It's currently just set from the union of the leader and follower brokers (matching the behavior of bin/kafka-reassign-partitions.sh).\n\n```go\nfunc (b BrokerThrottle) ConfigEntries() []kafka.ConfigEntry\n```\nConfigEntries returns the kafka config entries associated with this broker throttle.\n\n```go\ntype Client interface {\n\t// GetClusterID gets the ID of the cluster.\n\tGetClusterID(ctx context.Context) (string, error)\n\n\t// GetBrokers gets information about all brokers in the cluster.\n\tGetBrokers(ctx context.Context, ids []int) ([]BrokerInfo, error)\n\n\t// GetControllerID get the active controller broker ID in the cluster.\n\tGetControllerID(ctx context.Context) (int, error)\n\n\t// GetBrokerIDs get the IDs of all brokers in the cluster.\n\tGetBrokerIDs(ctx context.Context) ([]int, error)\n\n\t// GetConnector gets the Connector instance for this cluster.\n\tGetConnector() *Connector\n\n\t// GetTopics gets full information about each topic in the cluster.\n\tGetTopics(\n\t\tctx context.Context,\n\t\tnames []string,\n\t\tdetailed bool,\n\t) ([]TopicInfo, error)\n\n\t// GetTopicNames gets just the names of each topic in the cluster.\n\tGetTopicNames(ctx context.Context) ([]string, error)\n\n\t// GetTopic gets the details of a single topic in the cluster.\n\tGetTopic(\n\t\tctx context.Context,\n\t\tname string,\n\t\tdetailed bool,\n\t) (TopicInfo, error)\n\n\t// DeleteTopic deletes a single topic in the cluster.\n\tDeleteTopic(ctx context.Context, topic string) error\n\n\t// GetACLs gets full information about each ACL in the cluster.\n\tGetACLs(\n\t\tctx context.Context,\n\t\tfilter kafka.ACLFilter,\n\t) ([]ACLInfo, error)\n\n\t// GetAllTopicsMetadata performs kafka-go metadata call to get topic information\n\tGetAllTopicsMetadata(ctx context.Context) (*kafka.MetadataResponse, error)\n\n\t// GetUsers gets information about users in the cluster.\n\tGetUsers(\n\t\tctx context.Context,\n\t\tnames []string,\n\t) ([]UserInfo, error)\n\n\t// UpdateTopicConfig updates the configuration for the argument topic. It returns the config\n\t// keys that were updated.\n\tUpdateTopicConfig(\n\t\tctx context.Context,\n\t\tname string,\n\t\tconfigEntries []kafka.ConfigEntry,\n\t\toverwrite bool,\n\t) ([]string, error)\n\n\t// UpdateBrokerConfig updates the configuration for the argument broker. It returns the config\n\t// keys that were updated.\n\tUpdateBrokerConfig(\n\t\tctx context.Context,\n\t\tid int,\n\t\tconfigEntries []kafka.ConfigEntry,\n\t\toverwrite bool,\n\t) ([]string, error)\n\n\t// CreateTopic creates a topic in the cluster.\n\tCreateTopic(\n\t\tctx context.Context,\n\t\tconfig kafka.TopicConfig,\n\t) error\n\n\t// CreateACLs creates ACLs in the cluster.\n\tCreateACLs(\n\t\tctx context.Context,\n\t\tacls []kafka.ACLEntry,\n\t) error\n\n\t// DeleteACLs deletes ACLs in the cluster.\n\tDeleteACLs(\n\t\tctx context.Context,\n\t\tfilters []kafka.DeleteACLsFilter,\n\t) (*kafka.DeleteACLsResponse, error)\n\n\t// UpsertUser creates or updates an user in zookeeper.\n\tUpsertUser(\n\t\tctx context.Context,\n\t\tuser kafka.UserScramCredentialsUpsertion,\n\t) error\n\n\t// AssignPartitions sets the replica broker IDs for one or more partitions in a topic.\n\tAssignPartitions(\n\t\tctx context.Context,\n\t\ttopic string,\n\t\tassignments []PartitionAssignment,\n\t) error\n\n\t// AddPartitions extends a topic by adding one or more new partitions to it.\n\tAddPartitions(\n\t\tctx context.Context,\n\t\ttopic string,\n\t\tnewAssignments []PartitionAssignment,\n\t) error\n\n\t// RunLeaderElection triggers a leader election for one or more partitions in a topic.\n\tRunLeaderElection(\n\t\tctx context.Context,\n\t\ttopic string,\n\t\tpartitions []int,\n\t) error\n\n\t// AcquireLock acquires a lock that can be used to prevent simultaneous changes to a topic.\n\tAcquireLock(ctx context.Context, path string) (zk.Lock, error)\n\n\t// LockHeld returns whether a lock is currently held for the given path.\n\tLockHeld(ctx context.Context, path string) (bool, error)\n\n\t// GetSupportedFeatures gets the features supported by the cluster for this client.\n\tGetSupportedFeatures() SupportedFeatures\n\n\t// Close closes the client.\n\tClose() error\n}\n```\nClient is an interface for interacting with a cluster for administrative tasks.\n\n```go\ntype Connector struct {\n\tConfig      ConnectorConfig\n\tDialer      *kafka.Dialer\n\tKafkaClient *kafka.Client\n}\n```\nConnector is a wrapper around the low-level, kafka-go dialer and client.\n\n```go\nfunc NewConnector(config ConnectorConfig) (*Connector, error)\n```\nNewConnector contructs a new Connector instance given the argument config.\n\n```go\ntype ConnectorConfig struct {\n\tBrokerAddr  string\n\tTLS         TLSConfig\n\tSASL        SASLConfig\n\tConnTimeout time.Duration\n}\n```\nConnectorConfig contains the configuration used to contruct a connector.\n\n```go\ntype CredentialInfo struct {\n\tScramMechanism ScramMechanism `json:\"scramMechanism\"`\n\tIterations     int            `json:\"iterations\"`\n}\n```\nCredentialInfo represents read only information about a users credentials in zookeeper.\n\n```go\ntype PartitionAssignment struct {\n\tID       int   `json:\"id\"`\n\tReplicas []int `json:\"replicas\"`\n}\n```\nPartitionAssignment contains the actual or desired assignment of replicas in a topic partition.\n\n```go\nfunc AssignmentsToUpdate(\n\tcurrent []PartitionAssignment,\n\tdesired []PartitionAssignment,\n) []PartitionAssignment\n```\nAssignmentsToUpdate returns the subset of assignments that need to be updated given the current and desired states.\n\n```go\nfunc CopyAssignments(\n\tcurr []PartitionAssignment,\n) []PartitionAssignment\n```\nCopyAssignments returns a deep copy of the argument PartitionAssignment slice.\n\n```go\nfunc ReplicasToAssignments(\n\treplicaSlices [][]int,\n) []PartitionAssignment\n```\nReplicasToAssignments converts a slice of slices to a slice of PartitionAssignments, assuming that the argument slices are in partition order. Used for unit tests.\n\n```go\nfunc (a PartitionAssignment) Copy() PartitionAssignment\n```\nCopy returns a deep copy of this PartitionAssignment.\n\n```go\nfunc (a PartitionAssignment) DistinctRacks(\n\tbrokerRacks map[int]string,\n) map[string]struct{}\n```\nDistinctRacks returns a map of the distinct racks in this PartitionAssignment.\n\n```go\nfunc (a PartitionAssignment) Index(replica int) int\n```\nIndex returns the index of the argument replica, or -1 if it can't be found.\n\n```go\ntype PartitionInfo struct {\n\tTopic           string `json:\"topic\"`\n\tID              int    `json:\"ID\"`\n\tLeader          int    `json:\"leader\"`\n\tVersion         int    `json:\"version\"`\n\tReplicas        []int  `json:\"replicas\"`\n\tISR             []int  `json:\"isr\"`\n\tControllerEpoch int    `json:\"controllerEpoch\"`\n\tLeaderEpoch     int    `json:\"leaderEpoch\"`\n}\n```\nPartitionInfo represents the information stored about a topic partition in zookeeper.\n\n```go\nfunc (p PartitionInfo) NumRacks(brokerRacks map[int]string) (int, error)\n```\nNumRacks returns the number of distinct racks in the partition.\n\n```go\nfunc (p PartitionInfo) Racks(brokerRacks map[int]string) ([]string, error)\n```\nRacks returns a slice of all racks for the partition replicas.\n\n```go\ntype PartitionLeaderState string\n```\n\n```go\nconst (\n\tCorrectLeader PartitionLeaderState = \"OK\"\n\tWrongLeader   PartitionLeaderState = \"Wrong\"\n)\n```\n\n```go\ntype PartitionStatus string\n```\n\n```go\nconst (\n\tOk              PartitionStatus = \"OK\"\n\tOffline         PartitionStatus = \"Offline\"\n\tUnderReplicated PartitionStatus = \"Under-replicated\"\n)\n```\n\n```go\nfunc GetPartitionStatus(partition kafka.Partition) PartitionStatus\n```\nGet the Partition Status - ok - offline - under-replicated\n\nNOTE: partition is 1. offline - if ListenerNotFound Error observed for leader partition 2. underreplicated - if number of isrs are lesser than the replicas\n\n```go\nfunc StringToPartitionStatus(status string) (PartitionStatus, bool)\n```\nCheck if a string is valid PartitionStatus type\n\n```go\nfunc (p *PartitionStatus) Set(v string) error\n```\nSet is used by Cobra to set the value of a variable from a Cobra flag.\n\n```go\nfunc (p *PartitionStatus) String() string\n```\nString is used by Cobra in help text.\n\n```go\nfunc (p *PartitionStatus) Type() string\n```\nType is used by Cobra in help text.\n\n```go\ntype PartitionStatusInfo struct {\n\tTopic       string\n\tPartition   kafka.Partition\n\tStatus      PartitionStatus\n\tLeaderState PartitionLeaderState\n}\n```\n\n```go\nfunc (p PartitionStatusInfo) Racks(brokerRacks map[int]string) []string\n```\nRacks returns a slice of all racks for the partition replicas.\n\n```go\ntype PartitionThrottle struct {\n\tPartition int\n\tBroker    int\n}\n```\nPartitionThrottle represents a throttle being applied to a single partition, broker combination.\n\n```go\nfunc FollowerPartitionThrottles(\n\tcurr []PartitionAssignment,\n\tdesired []PartitionAssignment,\n) []PartitionThrottle\n```\nFollowerPartitionThrottles returns a slice of PartitionThrottles that we should apply on the follower side.\n\nSee [https://kafka.apache.org/0101/documentation.html](https://kafka.apache.org/0101/documentation.html) for discussion on how these should be applied.\n\n```go\nfunc LeaderPartitionThrottles(\n\tcurr []PartitionAssignment,\n\tdesired []PartitionAssignment,\n) []PartitionThrottle\n```\nLeaderPartitionThrottles returns a slice of PartitionThrottles that we should apply on the leader side.\n\nSee [https://kafka.apache.org/0101/documentation.html](https://kafka.apache.org/0101/documentation.html) for discussion on how these should be applied.\n\n```go\nfunc ParsePartitionThrottleStr(valuesStr string) ([]PartitionThrottle, error)\n```\nParsePartitionThrottleStr converts a throttle config string from zk into a slice of PartitionThrottle structs.\n\n```go\nfunc (p PartitionThrottle) String() string\n```\n\n```go\ntype PatternType kafka.PatternType\n```\nPatternType presents the Kafka pattern type. We need to subtype this to be able to define methods to satisfy the Value interface from Cobra so we can use it as a Cobra flag.\n\n```go\nfunc (p *PatternType) Set(v string) error\n```\nSet is used by Cobra to set the value of a variable from a Cobra flag.\n\n```go\nfunc (p *PatternType) String() string\n```\nString is used both by fmt.Print and by Cobra in help text.\n\n```go\nfunc (r *PatternType) Type() string\n```\nType is used by Cobra in help text.\n\n```go\ntype ResourceType kafka.ResourceType\n```\nResourceType presents the Kafka resource type. We need to subtype this to be able to define methods to satisfy the Value interface from Cobra so we can use it as a Cobra flag.\n\n```go\nfunc (r *ResourceType) Set(v string) error\n```\nSet is used by Cobra to set the value of a variable from a Cobra flag.\n\n```go\nfunc (r *ResourceType) String() string\n```\nString is used both by fmt.Print and by Cobra in help text.\n\n```go\nfunc (r *ResourceType) Type() string\n```\nType is used by Cobra in help text.\n\n```go\ntype SASLConfig struct {\n\tEnabled           bool\n\tMechanism         SASLMechanism\n\tUsername          string\n\tPassword          string\n\tSecretsManagerArn string\n}\n```\nSASLConfig stores the SASL-related configuration for a connection.\n\n```go\ntype SASLMechanism string\n```\nSASLMechanism is the name of a SASL mechanism that will be used for client authentication.\n\n```go\nconst (\n\tSASLMechanismAWSMSKIAM   SASLMechanism = \"aws-msk-iam\"\n\tSASLMechanismPlain       SASLMechanism = \"plain\"\n\tSASLMechanismScramSHA256 SASLMechanism = \"scram-sha-256\"\n\tSASLMechanismScramSHA512 SASLMechanism = \"scram-sha-512\"\n)\n```\n\n```go\nfunc SASLNameToMechanism(name string) (SASLMechanism, error)\n```\nSASLNameToMechanism converts the argument SASL mechanism name string to a valid instance of the SASLMechanism enum.\n\n```go\ntype ScramMechanism kafka.ScramMechanism\n```\nScramMechanism represents the ScramMechanism used for a users credential in zookeeper.\n\n```go\nfunc (s *ScramMechanism) String() string\n```\n\n```go\ntype SupportedFeatures struct {\n\t// Reads indicates whether the client supports reading basic cluster information\n\t// (metadata, configs, etc.).\n\tReads bool\n\n\t// Applies indicates whether the client supports the functionality required for applying\n\t// (e.g., changing configs, electing leaders, etc.).\n\tApplies bool\n\n\t// Locks indicates whether the client supports locking.\n\tLocks bool\n\n\t// DynamicBrokerConfigs indicates whether the client can return dynamic broker configs\n\t// like leader.replication.throttled.rate.\n\tDynamicBrokerConfigs bool\n\n\t// ACLs indicates whether the client supports access control levels.\n\tACLs bool\n\n\t// Users indicates whether the client supports SASL Users.\n\tUsers bool\n}\n```\nSupportedFeatures provides a summary of what an admin client supports.\n\n```go\ntype TLSConfig struct {\n\tEnabled    bool\n\tCertPath   string\n\tKeyPath    string\n\tCACertPath string\n\tServerName string\n\tSkipVerify bool\n}\n```\nTLSConfig stores the TLS-related configuration for a connection.\n\n```go\ntype TopicInfo struct {\n\tName       string            `json:\"name\"`\n\tConfig     map[string]string `json:\"config\"`\n\tPartitions []PartitionInfo   `json:\"partitions\"`\n\tVersion    int               `json:\"version\"`\n}\n```\nTopicInfo represents the information stored about a topic in zookeeper.\n\n```go\nfunc (t TopicInfo) AllLeadersCorrect() bool\n```\nAllLeadersCorrect returns whether leader == replicas\\[0] for all partitions.\n\n```go\nfunc (t TopicInfo) AllReplicasInSync() bool\n```\nAllReplicasInSync returns whether all partitions have ISR == replicas (ignoring order).\n\n```go\nfunc (t TopicInfo) IsThrottled() bool\n```\nIsThrottled determines whether the topic has any throttles in its config.\n\n```go\nfunc (t TopicInfo) MaxISR() int\n```\nMaxISR returns the maximum number of in-sync replicas across all partitions in a topic.\n\n```go\nfunc (t TopicInfo) MaxReplication() int\n```\nMaxReplication returns the maximum number of replicas across all partitions in a topic.\n\n```go\nfunc (t TopicInfo) OutOfSyncPartitions(subset []int) []PartitionInfo\n```\nOutOfSyncPartitions returns the partitions for which ISR != replicas (ignoring order).\n\n```go\nfunc (t TopicInfo) PartitionIDs() []int\n```\nPartitionIDs returns an ordered slice of partition IDs for a topic.\n\n```go\nfunc (t TopicInfo) RackCounts(brokerRacks map[int]string) (int, int, error)\n```\nRackCounts returns the minimum and maximum distinct rack counts across all partitions in a topic.\n\n```go\nfunc (t TopicInfo) Retention() time.Duration\n```\nRetention returns the retention duration implied by a topic config. If unset, it returns 0.\n\n```go\nfunc (t TopicInfo) ToAssignments() []PartitionAssignment\n```\nToAssignments converts a topic to a slice of partition assignments.\n\n```go\nfunc (t TopicInfo) WrongLeaderPartitions(subset []int) []PartitionInfo\n```\nWrongLeaderPartitions returns the partitions where leader != replicas\\[0].\n\n```go\ntype UserInfo struct {\n\tName            string           `json:\"name\"`\n\tCredentialInfos []CredentialInfo `json:\"credentialInfos\"`\n}\n```\nUserInfo represents the information stored about a user in zookeeper.\n\n```go\ntype ZKAdminClient struct {\n\tConnector *Connector\n\t// contains filtered or unexported fields\n}\n```\nZKAdminClient is a general client for interacting with a kafka cluster that assumes zookeeper access. Most interactions are done via the latter, but a few (e.g., creating topics or getting the controller address) are done via the broker API instead.\n\n```go\nfunc NewZKAdminClient(\n\tctx context.Context,\n\tconfig ZKAdminClientConfig,\n) (*ZKAdminClient, error)\n```\nNewZKAdminClient creates and returns a new Client instance.\n\n```go\nfunc (c *ZKAdminClient) AcquireLock(\n\tctx context.Context,\n\tpath string,\n) (zk.Lock, error)\n```\nAcquireLock acquires and returns a lock from the underlying zookeeper client. The Unlock method should be called on the lock when it's safe to release.\n\n```go\nfunc (c *ZKAdminClient) AddPartitions(\n\tctx context.Context,\n\ttopic string,\n\tnewAssignments []PartitionAssignment,\n) error\n```\nAddPartitions adds one or more partitions to an existing topic. Unlike AssignPartitions, this directly updates the topic's partition config in zookeeper.\n\n```go\nfunc (c *ZKAdminClient) AssignPartitions(\n\tctx context.Context,\n\ttopic string,\n\tassignments []PartitionAssignment,\n) error\n```\nAssignPartitions notifies the cluster to begin a partition reassignment. This should only be used for existing partitions; to create new partitions, use the AddPartitions method.\n\n```go\nfunc (c *ZKAdminClient) Close() error\n```\nClose closes the connections in the underlying zookeeper client.\n\n```go\nfunc (c *ZKAdminClient) CreateACLs(\n\tctx context.Context,\n\tacls []kafka.ACLEntry,\n) error\n```\n\n```go\nfunc (c *ZKAdminClient) CreateTopic(\n\tctx context.Context,\n\tconfig kafka.TopicConfig,\n) error\n```\nCreateTopic creates a new topic with the argument config. It uses the topic creation API exposed on the controller broker.\n\n```go\nfunc (c *ZKAdminClient) DeleteACLs(\n\tctx context.Context,\n\tfilters []kafka.DeleteACLsFilter,\n) (*kafka.DeleteACLsResponse, error)\n```\n\n```go\nfunc (c *ZKAdminClient) DeleteTopic(ctx context.Context, topic string) error\n```\n\n```go\nfunc (c *ZKAdminClient) GetACLs(\n\tctx context.Context,\n\tfilter kafka.ACLFilter,\n) ([]ACLInfo, error)\n```\n\n```go\nfunc (c *ZKAdminClient) GetAllTopicsMetadata(\n\tctx context.Context,\n) (*kafka.MetadataResponse, error)\n```\n\n```go\nfunc (c *ZKAdminClient) GetBrokerIDs(ctx context.Context) ([]int, error)\n```\nGetBrokerIDs returns a slice of all broker IDs.\n\n```go\nfunc (c *ZKAdminClient) GetBrokers(\n\tctx context.Context,\n\tids []int,\n) ([]BrokerInfo, error)\n```\nGetBrokers gets information on one or more cluster brokers from zookeeper. If the argument ids is unset, then it fetches all brokers.\n\n```go\nfunc (c *ZKAdminClient) GetClusterID(\n\tctx context.Context,\n) (string, error)\n```\nGetClusterID gets the cluster ID from zookeeper. This ID is generated when the cluster is created and should be stable over the life of the cluster.\n\n```go\nfunc (c *ZKAdminClient) GetConnector() *Connector\n```\nGetConnector returns the Connector instance associated with this client.\n\n```go\nfunc (c *ZKAdminClient) GetControllerID(\n\tctx context.Context,\n) (int, error)\n```\nGetControllerID gets ID of the active controller broker\n\n```go\nfunc (c *ZKAdminClient) GetSupportedFeatures() SupportedFeatures\n```\nGetSupportedFeatures returns the features that are supported by this client.\n\n```go\nfunc (c *ZKAdminClient) GetTopic(\n\tctx context.Context,\n\tname string,\n\tdetailed bool,\n) (TopicInfo, error)\n```\nGetTopic is a wrapper around GetTopics(...) for getting information about a single topic.\n\n```go\nfunc (c *ZKAdminClient) GetTopicNames(ctx context.Context) ([]string, error)\n```\nGetTopicNames gets all topic names from zookeeper.\n\n```go\nfunc (c *ZKAdminClient) GetTopics(\n\tctx context.Context,\n\tnames []string,\n\tdetailed bool,\n) ([]TopicInfo, error)\n```\nGetTopics gets information about one or more cluster topics from zookeeper. If the argument names is unset, then it fetches all topics. The detailed parameter determines whether the ISRs and leaders are fetched for each partition.\n\n```go\nfunc (c *ZKAdminClient) GetUsers(\n\tctx context.Context,\n\tnames []string,\n) ([]UserInfo, error)\n```\n\n```go\nfunc (c *ZKAdminClient) LockHeld(\n\tctx context.Context,\n\tpath string,\n) (bool, error)\n```\nLockHeld determines whether the lock with the provided path is held (i.e., has children).\n\n```go\nfunc (c *ZKAdminClient) RunLeaderElection(\n\tctx context.Context,\n\ttopic string,\n\tpartitions []int,\n) error\n```\nRunLeaderElection triggers a leader election for the argument topic and partitions.\n\n```go\nfunc (c *ZKAdminClient) UpdateBrokerConfig(\n\tctx context.Context,\n\tid int,\n\tconfigEntries []kafka.ConfigEntry,\n\toverwrite bool,\n) ([]string, error)\n```\nUpdateBrokerConfig updates the config JSON for a cluster broker and sets a change notification so the cluster brokers are notified. If overwrite is true, then it will overwrite existing config entries.\n\nThe function returns the list of keys that were modified. If overwrite is set to false, this can be used to determine the subset of entries\n\n```go\nfunc (c *ZKAdminClient) UpdateTopicConfig(\n\tctx context.Context,\n\tname string,\n\tconfigEntries []kafka.ConfigEntry,\n\toverwrite bool,\n) ([]string, error)\n```\nUpdateTopicConfig updates the config JSON for a topic and sets a change notification so that the brokers are notified. If overwrite is true, then it will overwrite existing config entries.\n\nThe function returns the list of keys that were modified. If overwrite is set to false, this can be used to determine the subset of entries that were already set.\n\n```go\nfunc (c *ZKAdminClient) UpsertUser(\n\tctx context.Context,\n\tuser kafka.UserScramCredentialsUpsertion,\n) error\n```\n\n```go\ntype ZKAdminClientConfig struct {\n\tZKAddrs           []string\n\tZKPrefix          string\n\tBootstrapAddrs    []string\n\tExpectedClusterID string\n\tAwsCfg            aws.Config\n\tReadOnly          bool\n\tKafkaConnTimeout  time.Duration\n}\n```\nZKAdminClientConfig contains all of the parameters necessary to create a kafka admin client.\n\n","path":"github.com/segmentio/topicctl/pkg/admin","name":"admin","synopsis":"","isRedistributable":true}
