Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a different sources endpoint to get the rhc connection info #326

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions internal/api/connectors/sources/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ func NewSourcesClient(cfg *viper.Viper) SourcesConnector {
return NewSourcesClientWithHttpRequestDoer(cfg, &doer)
}

func (this *sourcesClientImpl) getRHCConnectionStatus(ctx context.Context, sourceId string) (status *RhcConnectionRead, err error) {
func (this *sourcesClientImpl) getRHCConnectionStatus(ctx context.Context, sourceId string) (*[]RhcConnectionCollection, error) {

utils.GetLogFromContext(ctx).Debugw("Sending Sources RHC Connection Request")

ID := ID(sourceId)

res, err := this.client.GetRhcConnectionWithResponse(ctx, ID)
params := GetSourcesRhcConnectionParams{}

res, err := this.client.GetSourcesRhcConnectionWithResponse(ctx, ID, &params)

if err != nil {
return nil, err
Expand Down Expand Up @@ -133,17 +136,29 @@ func (this *sourcesClientImpl) GetSourceConnectionDetails(ctx context.Context, s
return SourceConnectionStatus{}, err
}

rhcConnectionResponse, err := this.getRHCConnectionStatus(ctx, sourceID)
fmt.Println("sourcesResponse: ", sourcesResponse)

source := (*sourcesResponse)[0]

rhcConnectionResponse, err := this.getRHCConnectionStatus(ctx, string(*source.Id))

if err != nil {
return SourceConnectionStatus{}, err
}

source := (*sourcesResponse)[0]
fmt.Println("rhcConnectionResponse: ", rhcConnectionResponse)
fmt.Println("rhcConnectionResponse[0]: ", (*rhcConnectionResponse)[0])
fmt.Println("rhcConnectionResponse[0].Data: ", (*rhcConnectionResponse)[0].Data)

rhcInfo := (*rhcConnectionResponse)[0].Data

fmt.Println("rhcInfo: ", rhcInfo)
fmt.Println("rhcInfo[0]: ", (*rhcInfo)[0])

return SourceConnectionStatus{
ID: string(*source.Id),
SourceName: source.Name,
RhcID: rhcConnectionResponse.RhcId,
AvailabilityStatus: rhcConnectionResponse.AvailabilityStatus,
RhcID: (*rhcInfo)[0].RhcId,
AvailabilityStatus: (*rhcInfo)[0].AvailabilityStatus,
}, err
}
2 changes: 2 additions & 0 deletions internal/api/connectors/sources/sources.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/api/connectors/sources/sources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var _ = Describe("Sources", func() {
It("interperates response correctly", func() {
responses := []test.MockHttpResponse{
{StatusCode: 200, Body: `{"data": [{"id": "1", "name": "test", "availability_status": "connected"}]}`},
{StatusCode: 200, Body: `{"id": "1", "rhc_id": "6f37c752ba1c48b1bcf74ef8f585d8ee", "availability_status": "connected"}`},
{StatusCode: 200, Body: `[{"data": [{"id": "1", "rhc_id": "6f37c752ba1c48b1bcf74ef8f585d8ee", "availability_status": "connected"}]}]`},
}

doer := test.MockMultiResponseHttpClient(responses...)
Expand All @@ -37,7 +37,7 @@ var _ = Describe("Sources", func() {
It("interperates response correctly if fields are missing", func() {
responses := []test.MockHttpResponse{
{StatusCode: 200, Body: `{"data": [{"id": "1", "name": "test"}]}`},
{StatusCode: 200, Body: `{"id": "1"}`},
{StatusCode: 200, Body: `[{"data": [{"id": "1"}]}]`},
}

doer := test.MockMultiResponseHttpClient(responses...)
Expand Down
Loading