use serde::{Deserialize, Serialize}; /*
                                      * Compute Engine API
                                      *
                                      * Creates and runs virtual machines on Google Cloud Platform.
                                      *
                                      * The version of the OpenAPI document: v1
                                      *
                                      * Generated by: https://openapi-generator.tech
                                      */

use crate::google_rest_apis::compute_v1::models;

/// PathMatcher : A matcher for the path portion of the URL. The BackendService from the longest-matched rule will serve the URL. If no rule was matched, the default service is used.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct PathMatcher {
    #[serde(rename = "defaultRouteAction", skip_serializing_if = "Option::is_none")]
    pub default_route_action: Option<Box<models::HttpRouteAction>>,
    /// The full or partial URL to the BackendService resource. This URL is used if none of the pathRules or routeRules defined by this PathMatcher are matched. For example, the following are all valid URLs to a BackendService resource: - https://www.googleapis.com/compute/v1/projects/project /global/backendServices/backendService - compute/v1/projects/project/global/backendServices/backendService - global/backendServices/backendService If defaultRouteAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending the request to the backend. However, if defaultService is specified, defaultRouteAction cannot contain any weightedBackendServices. Conversely, if defaultRouteAction specifies any weightedBackendServices, defaultService must not be specified. Only one of defaultService, defaultUrlRedirect , or defaultRouteAction.weightedBackendService must be set. Authorization requires one or more of the following Google IAM permissions on the specified resource default_service: - compute.backendBuckets.use - compute.backendServices.use
    #[serde(rename = "defaultService", skip_serializing_if = "Option::is_none")]
    pub default_service: Option<String>,
    #[serde(rename = "defaultUrlRedirect", skip_serializing_if = "Option::is_none")]
    pub default_url_redirect: Option<Box<models::HttpRedirectAction>>,
    /// An optional description of this resource. Provide this property when you create the resource.
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(rename = "headerAction", skip_serializing_if = "Option::is_none")]
    pub header_action: Option<Box<models::HttpHeaderAction>>,
    /// The name to which this PathMatcher is referred by the HostRule.
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// The list of path rules. Use this list instead of routeRules when routing based on simple path matching is all that's required. The order by which path rules are specified does not matter. Matches are always done on the longest-path-first basis. For example: a pathRule with a path /a/b/c/_* will match before /a/b/_* irrespective of the order in which those paths appear in this list. Within a given pathMatcher, only one of pathRules or routeRules must be set.
    #[serde(rename = "pathRules", skip_serializing_if = "Option::is_none")]
    pub path_rules: Option<Vec<models::PathRule>>,
    /// The list of HTTP route rules. Use this list instead of pathRules when advanced route matching and routing actions are desired. routeRules are evaluated in order of priority, from the lowest to highest number. Within a given pathMatcher, you can set only one of pathRules or routeRules.
    #[serde(rename = "routeRules", skip_serializing_if = "Option::is_none")]
    pub route_rules: Option<Vec<models::HttpRouteRule>>,
}

impl PathMatcher {
    /// A matcher for the path portion of the URL. The BackendService from the longest-matched rule will serve the URL. If no rule was matched, the default service is used.
    pub fn new() -> PathMatcher {
        PathMatcher {
            default_route_action: None,
            default_service: None,
            default_url_redirect: None,
            description: None,
            header_action: None,
            name: None,
            path_rules: None,
            route_rules: None,
        }
    }
}
