Skip to content

Commit

Permalink
Merge branch 'master' into load-test-results
Browse files Browse the repository at this point in the history
  • Loading branch information
TharmiganK authored Feb 24, 2025
2 parents e919747 + 6b5198e commit ebbd962
Showing 1 changed file with 58 additions and 58 deletions.
116 changes: 58 additions & 58 deletions ballerina/http_client_endpoint.bal
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,42 @@ public client isolated class Client {
return;
}

# The client resource function to send HTTP GET requests to HTTP endpoints.
#
# + path - Request path
# + headers - The entity headers
# + targetType - HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding
# + params - The query parameters
# + return - The response or the payload (if the `targetType` is configured) or an `http:ClientError` if failed to
# establish the communication with the upstream server or a data binding failure
isolated resource function get [PathParamType ...path](map<string|string[]>? headers = (), TargetType targetType = <>,
*QueryParams params) returns targetType|ClientError = @java:Method {
'class: "io.ballerina.stdlib.http.api.client.actions.HttpClientAction",
name: "getResource"
} external;

# The `Client.get()` function can be used to send HTTP GET requests to HTTP endpoints.
#
# + path - Request path
# + headers - The entity headers
# + targetType - HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding
# + return - The response or the payload (if the `targetType` is configured) or an `http:ClientError` if failed to
# establish the communication with the upstream server or a data binding failure
remote isolated function get(string path, map<string|string[]>? headers = (), TargetType targetType = <>)
returns targetType|ClientError = @java:Method {
'class: "io.ballerina.stdlib.http.api.client.actions.HttpClientAction"
} external;

private isolated function processGet(string path, map<string|string[]>? headers, TargetType targetType)
returns Response|stream<SseEvent, error?>|anydata|ClientError {
Request req = buildRequestWithHeaders(headers);
Response|ClientError response = self.httpClient->get(path, message = req);
if observabilityEnabled && response is Response {
addObservabilityInformation(path, HTTP_GET, response.statusCode, self.url);
}
return processResponse(response, targetType, self.requireValidation, self.requireLaxDataBinding);
}

# The client resource function to send HTTP POST requests to HTTP endpoints.
#
# + path - Request path
Expand Down Expand Up @@ -143,86 +179,86 @@ public client isolated class Client {
return processResponse(response, targetType, self.requireValidation, self.requireLaxDataBinding);
}

# The client resource function to send HTTP PATCH requests to HTTP endpoints.
# The client resource function to send HTTP DELETE requests to HTTP endpoints.
#
# + path - Request path
# + message - An HTTP outbound request or any allowed payload
# + message - An optional HTTP outbound request or any allowed payload
# + headers - The entity headers
# + mediaType - The MIME type header of the request entity
# + targetType - HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding
# + params - The query parameters
# + return - The response or the payload (if the `targetType` is configured) or an `http:ClientError` if failed to
# establish the communication with the upstream server or a data binding failure
isolated resource function patch [PathParamType ...path](RequestMessage message, map<string|string[]>? headers = (),
isolated resource function delete [PathParamType ...path](RequestMessage message = (), map<string|string[]>? headers = (),
string? mediaType = (), TargetType targetType = <>, *QueryParams params) returns targetType|ClientError = @java:Method {
'class: "io.ballerina.stdlib.http.api.client.actions.HttpClientAction",
name: "patchResource"
name: "deleteResource"
} external;

# The `Client.patch()` function can be used to send HTTP PATCH requests to HTTP endpoints.
# The `Client.delete()` function can be used to send HTTP DELETE requests to HTTP endpoints.
#
# + path - Resource path
# + message - An HTTP outbound request or any allowed payload
# + message - An optional HTTP outbound request message or any allowed payload
# + mediaType - The MIME type header of the request entity
# + headers - The entity headers
# + targetType - HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding
# + return - The response or the payload (if the `targetType` is configured) or an `http:ClientError` if failed to
# establish the communication with the upstream server or a data binding failure
remote isolated function patch(string path, RequestMessage message, map<string|string[]>? headers = (),
string? mediaType = (), TargetType targetType = <>)
remote isolated function delete(string path, RequestMessage message = (),
map<string|string[]>? headers = (), string? mediaType = (), TargetType targetType = <>)
returns targetType|ClientError = @java:Method {
'class: "io.ballerina.stdlib.http.api.client.actions.HttpClientAction"
} external;

private isolated function processPatch(string path, RequestMessage message, TargetType targetType,
private isolated function processDelete(string path, RequestMessage message, TargetType targetType,
string? mediaType, map<string|string[]>? headers) returns Response|stream<SseEvent, error?>|anydata|ClientError {
Request req = check buildRequest(message, mediaType);
populateOptions(req, mediaType, headers);
Response|ClientError response = self.httpClient->patch(path, req);
Response|ClientError response = self.httpClient->delete(path, req);
if observabilityEnabled && response is Response {
addObservabilityInformation(path, HTTP_PATCH, response.statusCode, self.url);
addObservabilityInformation(path, HTTP_DELETE, response.statusCode, self.url);
}
return processResponse(response, targetType, self.requireValidation, self.requireLaxDataBinding);
}

# The client resource function to send HTTP DELETE requests to HTTP endpoints.
# The client resource function to send HTTP PATCH requests to HTTP endpoints.
#
# + path - Request path
# + message - An optional HTTP outbound request or any allowed payload
# + message - An HTTP outbound request or any allowed payload
# + headers - The entity headers
# + mediaType - The MIME type header of the request entity
# + targetType - HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding
# + params - The query parameters
# + return - The response or the payload (if the `targetType` is configured) or an `http:ClientError` if failed to
# establish the communication with the upstream server or a data binding failure
isolated resource function delete [PathParamType ...path](RequestMessage message = (), map<string|string[]>? headers = (),
isolated resource function patch [PathParamType ...path](RequestMessage message, map<string|string[]>? headers = (),
string? mediaType = (), TargetType targetType = <>, *QueryParams params) returns targetType|ClientError = @java:Method {
'class: "io.ballerina.stdlib.http.api.client.actions.HttpClientAction",
name: "deleteResource"
name: "patchResource"
} external;

# The `Client.delete()` function can be used to send HTTP DELETE requests to HTTP endpoints.
# The `Client.patch()` function can be used to send HTTP PATCH requests to HTTP endpoints.
#
# + path - Resource path
# + message - An optional HTTP outbound request message or any allowed payload
# + message - An HTTP outbound request or any allowed payload
# + mediaType - The MIME type header of the request entity
# + headers - The entity headers
# + targetType - HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding
# + return - The response or the payload (if the `targetType` is configured) or an `http:ClientError` if failed to
# establish the communication with the upstream server or a data binding failure
remote isolated function delete(string path, RequestMessage message = (),
map<string|string[]>? headers = (), string? mediaType = (), TargetType targetType = <>)
remote isolated function patch(string path, RequestMessage message, map<string|string[]>? headers = (),
string? mediaType = (), TargetType targetType = <>)
returns targetType|ClientError = @java:Method {
'class: "io.ballerina.stdlib.http.api.client.actions.HttpClientAction"
} external;

private isolated function processDelete(string path, RequestMessage message, TargetType targetType,
private isolated function processPatch(string path, RequestMessage message, TargetType targetType,
string? mediaType, map<string|string[]>? headers) returns Response|stream<SseEvent, error?>|anydata|ClientError {
Request req = check buildRequest(message, mediaType);
populateOptions(req, mediaType, headers);
Response|ClientError response = self.httpClient->delete(path, req);
Response|ClientError response = self.httpClient->patch(path, req);
if observabilityEnabled && response is Response {
addObservabilityInformation(path, HTTP_DELETE, response.statusCode, self.url);
addObservabilityInformation(path, HTTP_PATCH, response.statusCode, self.url);
}
return processResponse(response, targetType, self.requireValidation, self.requireLaxDataBinding);
}
Expand Down Expand Up @@ -252,42 +288,6 @@ public client isolated class Client {
}
return response;
}

# The client resource function to send HTTP GET requests to HTTP endpoints.
#
# + path - Request path
# + headers - The entity headers
# + targetType - HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding
# + params - The query parameters
# + return - The response or the payload (if the `targetType` is configured) or an `http:ClientError` if failed to
# establish the communication with the upstream server or a data binding failure
isolated resource function get [PathParamType ...path](map<string|string[]>? headers = (), TargetType targetType = <>,
*QueryParams params) returns targetType|ClientError = @java:Method {
'class: "io.ballerina.stdlib.http.api.client.actions.HttpClientAction",
name: "getResource"
} external;

# The `Client.get()` function can be used to send HTTP GET requests to HTTP endpoints.
#
# + path - Request path
# + headers - The entity headers
# + targetType - HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding
# + return - The response or the payload (if the `targetType` is configured) or an `http:ClientError` if failed to
# establish the communication with the upstream server or a data binding failure
remote isolated function get(string path, map<string|string[]>? headers = (), TargetType targetType = <>)
returns targetType|ClientError = @java:Method {
'class: "io.ballerina.stdlib.http.api.client.actions.HttpClientAction"
} external;

private isolated function processGet(string path, map<string|string[]>? headers, TargetType targetType)
returns Response|stream<SseEvent, error?>|anydata|ClientError {
Request req = buildRequestWithHeaders(headers);
Response|ClientError response = self.httpClient->get(path, message = req);
if observabilityEnabled && response is Response {
addObservabilityInformation(path, HTTP_GET, response.statusCode, self.url);
}
return processResponse(response, targetType, self.requireValidation, self.requireLaxDataBinding);
}

# The client resource function to send HTTP OPTIONS requests to HTTP endpoints.
#
Expand Down

0 comments on commit ebbd962

Please sign in to comment.