Querying the Details of a Forwarding Policy
Function
This API is used to view the details of a forwarding policy.
Calling Method
For details, see Calling APIs.
URI
GET /v3/{project_id}/elb/l7policies/{l7policy_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Definition: Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID. Constraints: N/A Range: The value can contain a maximum of 32 characters, including digits and lowercase letters. Default value: N/A |
l7policy_id |
Yes |
String |
Definition: Specifies the forwarding policy ID. Constraints: N/A Range: N/A Default value: N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Definition: Specifies the token used for IAM authentication. Constraints: N/A Range: N/A Default value: N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
request_id |
String |
Definition: Specifies the request ID. Range: The value is automatically generated, and can contain characters including digits, lowercase letters, and hyphens (-). |
l7policy |
L7Policy object |
Definition: Specifies the forwarding policy. |
Parameter |
Type |
Description |
---|---|---|
action |
String |
Definition: Specifies the action of the forwarding policy. Range:
|
admin_state_up |
Boolean |
Definition: Specifies the administrative status of the forwarding policy. Range: The value can only be true. |
description |
String |
Definition: Provides supplementary information about the forwarding policy. Range: N/A |
id |
String |
Definition: Specifies the forwarding policy ID. Range: N/A |
listener_id |
String |
Definition: Specifies the ID of the listener with which the forwarding policy is associated. Range: N/A |
name |
String |
Definition: Specifies the forwarding policy name. Range: N/A |
position |
Integer |
Definition: Specifies the priority of the forwarding policy. The priority cannot be updated. This parameter is unsupported. Please do not use it. |
priority |
Integer |
Definition: Specifies the priority of the forwarding policy. A smaller value indicates a higher priority. Range:
|
project_id |
String |
Definition: Specifies the ID of the project where the forwarding policy is used. Range: N/A |
provisioning_status |
String |
Definition: Specifies the provisioning status of the forwarding policy. Range:
|
redirect_pool_id |
String |
Definition: Specifies the ID of the backend server group to which requests will be forwarded. Range: N/A |
redirect_listener_id |
String |
Definition: Specifies the ID of the listener to which requests are redirected. Range: N/A |
redirect_url |
String |
Definition: Specifies the URL to which requests will be forwarded. Range: The value must be in the format of protocol://host:port/path?query. This parameter is unsupported. Please do not use it. |
rules |
Array of RuleRef objects |
Definition: Lists the forwarding rules in the forwarding policy. |
redirect_url_config |
RedirectUrlConfig object |
Definition: Specifies the URL to which requests are forwarded. |
redirect_pools_config |
Array of RedirectPoolsConfig objects |
Definition: Specifies the backend server groups that the requests are forwarded to. This parameter takes effect only when enhance_l7policy_enable is set to true. If this parameter is specified and enhance_l7policy_enable is set to false, an error will be returned. |
redirect_pools_sticky_session_config |
Definition: Specifies whether to enable sticky session for backend server groups configured for a forwarding policy. The load balancer generates a cookie after it receives a request from a client. All subsequent requests with the same cookie are routed to the same backend server group. |
|
redirect_pools_extend_config |
RedirectPoolsExtendConfig object |
Definition: Specifies the backend server group that requests are forwarded to. |
fixed_response_config |
FixtedResponseConfig object |
Definition: Specifies the configuration of the page that will be returned. |
created_at |
String |
Definition: Specifies the creation time. Range: The value must be a UTC time in the yyyy-MM-dd'T'HH:mm:ss'Z' format. Note: This parameter will not be returned for resources associated with existing dedicated load balancers and for resources associated with existing and new shared load balancers. |
updated_at |
String |
Definition: Specifies the update time. Range: The value must be a UTC time in the yyyy-MM-dd'T'HH:mm:ss'Z' format. Note: This parameter will not be returned for resources associated with existing dedicated load balancers and for resources associated with existing and new shared load balancers. |
enterprise_project_id |
String |
Definition: Specifies the enterprise project ID. Range: N/A |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Definition: Specifies the forwarding rule ID. Range: N/A |
Parameter |
Type |
Description |
---|---|---|
protocol |
String |
Definition: Specifies the protocol for redirection. Range:
|
host |
String |
Definition: Specifies the name of the host that requests are redirected to. Range: The value can contain only letters, digits, hyphens (-), and periods (.) and must start with a letter or digit. |
port |
String |
Definition: Specifies the port that requests are redirected to. Range: N/A |
path |
String |
Definition: Specifies the path that requests are redirected to. Range: The value can contain only letters, digits, and special characters: _~';@^-%#&$.*+?,=!:|\/()[]{} and must start with a slash (/). |
query |
String |
Definition: Specifies the query string set in the URL for redirection. The following is an example: In the URL https://www.example.com:8080/elb?type=loadbalancer, if this parameter is set to ${query}&name=my_name, the URL will be redirected to https://www.example.com:8080/elb?type=loadbalancer&name=my_name. In the example, ${query} indicates type=loadbalancer. Range: The value can contain only letters, digits, and the special characters: !$&'()*+,-./:;=?@^_`. The letters are case-sensitive. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the requested URL. |
status_code |
String |
Definition: Specifies the status code returned after the requests are redirected. Range:
|
insert_headers_config |
InsertHeadersConfig object |
Definition: Specifies the headers you want to write into the request that matches the forwarding rule. |
remove_headers_config |
RemoveHeadersConfig object |
Definition: Specifies the headers you want to remove from the request that matches the forwarding rule. |
Parameter |
Type |
Description |
---|---|---|
pool_id |
String |
Definition: Specifies the backend server group ID. Range: N/A |
weight |
Integer |
Definition: Specifies the weight of the backend server group. Requests are routed to backend server groups based on their weights. The larger the weight is, the higher proportion of requests the backend server group receives. If the weight is set to 0, the backend server group will not accept new requests. Range: 0 to 100 |
Parameter |
Type |
Description |
---|---|---|
enable |
Boolean |
Definition: Specifies whether to enable sticky session for backend server groups configured in a forwarding policy. Default value: false, indicating that sticky session is disabled. |
timeout |
Integer |
Definition: Specifies the stickiness duration, in minutes. Range: 1 to 1440 |
Parameter |
Type |
Description |
---|---|---|
rewrite_url_enable |
Boolean |
Definition: Specifies whether to set rewrite_url_enable to true. Range: The value can be true (enable this option) or false (disable this option). |
rewrite_url_config |
RewriteUrlConfig object |
Definition: Specifies the URL for the backend server group that requests are forwarded to. |
insert_headers_config |
InsertHeadersConfig object |
Definition: Specifies the headers you want to write into the request that matches the forwarding rule. |
remove_headers_config |
RemoveHeadersConfig object |
Definition: Specifies the headers you want to remove from the request that matches the forwarding rule. |
traffic_limit_config |
TrafficLimitConfig object |
Definition: Specifies how requests are limited. |
cors_config |
CorsConfig object |
Definition: Specifies the CORS configurations. |
traffic_mirror_config |
TrafficMirrorConfig object |
Definition: Specifies the traffic mirroring configuration. |
Parameter |
Type |
Description |
---|---|---|
host |
String |
Definition: Specifies the domain name of the host that requests are redirected to. Range: The value can contain letters, digits, hyphens (-), and periods (.), and must start with a letter or digit. |
path |
String |
Definition: Specifies the path that requests are redirected to. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the request URL. If the number of regular expression match groups is less than the specified number, ${path} is empty. If the dollar sign ($) is followed by a letter, the matching result is empty until the next special character appears, for example, $abc#123, and the matching result is #123. If the dollar sign ($) is followed by a special character, for example, $#, the matching result is $#. Range: The value must start with a slash (/) and can contain only letters, digits, and special characters: _~';@^-%#&$.+?,=!:|/() |
query |
String |
Definition: Specifies the query string set in the URL for redirection. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the request URL. If the number of regular expression match groups is less than the specified number, ${path} is empty. If the dollar sign ($) is followed by a letter, the matching result is empty until the next special character appears, for example, $abc#123, and the matching result is #123. If the dollar sign ($) is followed by a special character, for example, $#, the matching result is $#. Range: The value can contain only letters, digits, and the special characters: !$&'()+,-./:;=?@^_`. The letters are case-sensitive. |
Parameter |
Type |
Description |
---|---|---|
allow_origin |
Array of strings |
Definition: Specifies the origins that are allowed to access cross-origin resources through a browser. The origin can be a wildcard (*) or one or more URLs. Constraints:
|
allow_methods |
Array of strings |
Definition: Specifies the HTTP methods that the specified URLs can use to access cross-origin resources. Range: N/A |
allow_headers |
Array of strings |
Definition: Specifies the request headers that can be carried in CORS requests. Range: N/A |
expose_headers |
Array of strings |
Definition: Specifies the headers that can be exposed. Range: N/A |
allow_credentials |
Boolean |
Definition: Specifies whether to allow credentials in CORS requests. Range:
|
max_age |
Long |
Definition: Specifies the maximum duration a preflight request can be cached, in seconds. Range: -1 to 172800 |
Parameter |
Type |
Description |
---|---|---|
target_ids |
Array of strings |
Definition: Specifies the IDs of the backend server groups that traffic is mirrored to. Range: N/A |
mirror_request_body_enable |
Boolean |
Specifies whether to include the mirror request body. The default value is true. Range: N/A |
Parameter |
Type |
Description |
---|---|---|
status_code |
String |
Definition: Specifies the HTTP status code. Range: 200-299, 400-499, 500-599 |
content_type |
String |
Definition: Specifies the format of the returned body. Range:
|
message_body |
String |
Definition: Specifies the content of the response message body. Range: N/A |
insert_headers_config |
InsertHeadersConfig object |
Definition: Specifies the headers you want to write into the request that matches the forwarding rule. |
remove_headers_config |
RemoveHeadersConfig object |
Definition: Specifies the headers you want to remove from the request that matches the forwarding rule. |
traffic_limit_config |
TrafficLimitConfig object |
Definition: Specifies how requests are limited. |
Parameter |
Type |
Description |
---|---|---|
configs |
Array of InsertHeaderConfig objects |
Definition: Specifies the headers you want to write into the request that matches the forwarding rule. Constraints: N/A |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Definition: Specifies the key of the header you want to write into the request that matches the forwarding rule. Range: The value can contain 1 to 40 characters, including letters (case-insensitive), digits, hyphens (-), and underscores (_). |
value_type |
String |
Definition: Specifies the value type of the header. Range: USER_DEFINED, REFERENCE_HEADER, or SYSTEM_DEFINED |
value |
String |
Definition: Specifies the value of the header. Range: The value can contain 1 to 128 characters. ASCII codes 32 through 127 printable characters, asterisk (*), and question mark (?) are also supported. The value cannot start or end with a space. |
Parameter |
Type |
Description |
---|---|---|
configs |
Array of RemoveHeaderConfig objects |
Definition: Specifies the headers you want to remove from the request that matches the forwarding rule. Constraints: N/A |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Definition: Specifies the key of the header you want to remove from the request that matches the forwarding rule. Range: The value can contain 1 to 40 characters, including letters (case-insensitive), digits, hyphens (-), and underscores (_). |
Parameter |
Type |
Description |
---|---|---|
qps |
Integer |
Definition: Specifies the maximum number of queries per second (QPS). Range: 0 to 100000. Unit: count/s. 0 indicates that QPS is not limited. |
per_source_ip_qps |
Integer |
Definition: Specifies the maximum number of queries per second (QPS) from a source IP address (single client). Range: 0 to 100000. Unit: count/s. 0 indicates that QPS is not limited. |
burst |
Integer |
Definition: Specifies the allowed burst queries if the number of queries exceeds the value specified for qps. If the number of burst queries exceeds the value specified for burst, 503 Service Unavailable will be returned to the client. Range: 0 to 100000. Unit: count/s. |
Example Requests
Querying the details of a forwarding policy
GET https://{ELB_Endpoint}/v3/99a3fff0d03c428eac3678da6a7d0f24/elb/l7policies/cf4360fd-8631-41ff-a6f5-b72c35da74be
Example Responses
Status code: 200
Successful request.
{ "l7policy" : { "redirect_pool_id" : "768e9e8c-e7cb-4fef-b24b-af9399dbb240", "description" : "", "admin_state_up" : true, "rules" : [ { "id" : "c5c2d625-676b-431e-a4c7-c59cc2664881" } ], "project_id" : "7a9941d34fc1497d8d0797429ecfd354", "listener_id" : "cdb03a19-16b7-4e6b-bfec-047aeec74f56", "redirect_url" : null, "redirect_url_config" : null, "redirect_pools_config" : { "pool_id" : "722e9e8c-e7cb-4fef-b24b-af9399dbb240", "weight" : 12 }, "redirect_pools_sticky_session_config" : { "timeout" : 23, "enable" : false }, "fixed_response_config" : { "content_type" : "text/plain", "message_body" : "", "status_code" : "207" }, "redirect_listener_id" : null, "action" : "REDIRECT_TO_POOL", "position" : 100, "priority" : 1, "provisioning_status" : "ACTIVE", "id" : "01832d99-bbd8-4340-9d0c-6ff8f7a37307", "name" : "l7policy-67" }, "request_id" : "6be83ec4-623e-4840-a417-2fcdf8ad5dfa" }
SDK Sample Code
The SDK sample code is as follows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.elb.v3.region.ElbRegion; import com.huaweicloud.sdk.elb.v3.*; import com.huaweicloud.sdk.elb.v3.model.*; public class ShowL7PolicySolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); ElbClient client = ElbClient.newBuilder() .withCredential(auth) .withRegion(ElbRegion.valueOf("<YOUR REGION>")) .build(); ShowL7PolicyRequest request = new ShowL7PolicyRequest(); request.withL7policyId("{l7policy_id}"); try { ShowL7PolicyResponse response = client.showL7Policy(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkelb.v3.region.elb_region import ElbRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkelb.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = ElbClient.new_builder() \ .with_credentials(credentials) \ .with_region(ElbRegion.value_of("<YOUR REGION>")) \ .build() try: request = ShowL7PolicyRequest() request.l7policy_id = "{l7policy_id}" response = client.show_l7_policy(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := elb.NewElbClient( elb.ElbClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ShowL7PolicyRequest{} request.L7policyId = "{l7policy_id}" response, err := client.ShowL7Policy(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
Status Code |
Description |
---|---|
200 |
Successful request. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot