Skip to content

Client: Add new QueryRaw function#249

Merged
masnax merged 6 commits into
canonical:v3from
roosterfish:raw_query
Sep 9, 2024
Merged

Client: Add new QueryRaw function#249
masnax merged 6 commits into
canonical:v3from
roosterfish:raw_query

Conversation

@roosterfish
Copy link
Copy Markdown
Contributor

This PR adds another QueryRaw function to the client which allows accessing the raw *http.Response.
That is required for the canonical/microcloud#383 in order to access the remotes certificate used in the TLS connection.

Furthermore the parsing of API responses is moved into the public facing package to allow any user of QueryRaw to both access the raw response and parsing it as usual.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
This allows both the internal client code and externals that use the raw methods
to parse the response from the API.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Allow sending a query and getting the raw response.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
@roosterfish roosterfish changed the title Client: Add new QueryRaw function Client: Add new QueryRaw function Sep 6, 2024
@roosterfish roosterfish requested a review from masnax September 9, 2024 08:44
Copy link
Copy Markdown
Contributor

@masnax masnax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one tiny nit :)

Comment thread client/client.go Outdated
return c.QueryStruct(queryCtx, method, prefix, path, in, &out)
}

// QueryRaw is a helper for initiating a request on any endpoints defined external to microcluster. This function should be used for all client
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove This function should be used for all client methods defined externally from microcluster here since it's more of a special case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this up.
Had the same thought as you but left it in to clearly indicate that you should not use the internal QueryStruct/QueryStructRaw methods.

But probably at some time we will anyway revoke access to those so we can already start thinking this way. Removed :)

Allow sending a query and getting the raw response.
Externals can use the response.ParseResponse func to both access the raw
response but still parse it as usual.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
@masnax masnax merged commit a140913 into canonical:v3 Sep 9, 2024
masnax added a commit that referenced this pull request Sep 9, 2024
@roosterfish roosterfish deleted the raw_query branch December 9, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants