GetTopicConfigs calls GetTopicsConfigs for a single Topic and returns a single response
(ctx context.Context, topicName string, configNames []string)
| 120 | |
| 121 | // GetTopicConfigs calls GetTopicsConfigs for a single Topic and returns a single response |
| 122 | func (s *Service) GetTopicConfigs(ctx context.Context, topicName string, configNames []string) (*TopicConfig, *rest.Error) { |
| 123 | response, err := s.GetTopicsConfigs(ctx, []string{topicName}, configNames) |
| 124 | if err != nil { |
| 125 | return nil, &rest.Error{ |
| 126 | Err: err, |
| 127 | Status: http.StatusInternalServerError, |
| 128 | Message: fmt.Sprintf("Failed to get topic's config: %v", err.Error()), |
| 129 | IsSilent: false, |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | if val, exists := response[topicName]; exists { |
| 134 | if val.Error != nil && val.Error.Code == kerr.UnknownTopicOrPartition.Code { |
| 135 | return nil, &rest.Error{ |
| 136 | Err: errors.New("the requested topic does not exist"), |
| 137 | Status: http.StatusNotFound, |
| 138 | Message: fmt.Sprintf("Could not fetch topic config because the requested topic '%v' does not exist.", topicName), |
| 139 | IsSilent: false, |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | return response[topicName], nil |
| 145 | } |
| 146 | |
| 147 | // GetTopicsConfigs fetches all topic config options for the given set of topic names and config names and converts |
| 148 | // that information so that it is handy to use. Provide an empty array for configNames to describe all config entries. |