Merge "Fix identity resource link code"
This commit is contained in:
@@ -240,6 +240,14 @@ class KeystoneGenerator(OpenStackServerSourceBase):
|
||||
path_param.openstack["resource_link"] = (
|
||||
"identity/v3/domain.id"
|
||||
)
|
||||
if path_param.name == "project_id" and path_resource_names != [
|
||||
"projects"
|
||||
]:
|
||||
if not path_param.openstack:
|
||||
path_param.openstack = {}
|
||||
path_param.openstack["resource_link"] = (
|
||||
"identity/v3/project.id"
|
||||
)
|
||||
openapi_spec.components.parameters[global_param_name] = (
|
||||
path_param
|
||||
)
|
||||
|
||||
@@ -1079,6 +1079,7 @@ class RustCliGenerator(BaseGenerator):
|
||||
f"openstack_sdk::api::{'::'.join(link_res_name.split('/'))}::find as find_{link_res_name.split('/')[-1]}"
|
||||
)
|
||||
global_additional_imports.add("eyre::OptionExt")
|
||||
global_additional_imports.add("eyre::eyre")
|
||||
|
||||
# List of operation variants (based on the body)
|
||||
operation_variants = common.get_operation_variants(
|
||||
|
||||
@@ -420,6 +420,39 @@ Some({{ val }})
|
||||
}
|
||||
{%- if v.remote_name in ["user_id", "project_id", "domain_id"] %}
|
||||
else if self.path.{{ res_name }}.current_{{ res_name }} {
|
||||
{%- if v.remote_name == "domain_id" %}
|
||||
let token = client
|
||||
.get_auth_info()
|
||||
.ok_or_eyre("Cannot determine current authentication information")?
|
||||
.token;
|
||||
if let Some(domain) = token.domain {
|
||||
ep_builder.domain_id(domain.id.ok_or_eyre("Domain ID is missing in the auth")?);
|
||||
} else if let Some(project) = token.project {
|
||||
ep_builder.{{ v.remote_name }}(
|
||||
project
|
||||
.domain
|
||||
.ok_or_eyre("Domain information is missing in the project auth info")?
|
||||
.id
|
||||
.ok_or_eyre("Domain ID is missing in the project.domain auth info")?,
|
||||
);
|
||||
} else {
|
||||
return Err(eyre!("Current domain information can not be identified").into());
|
||||
}
|
||||
{%- elif v.remote_name == "project_id" %}
|
||||
let token = client
|
||||
.get_auth_info()
|
||||
.ok_or_eyre("Cannot determine current authentication information")?
|
||||
.token;
|
||||
if let Some(project) = token.project {
|
||||
ep_builder.{{ v.remote_name }}(
|
||||
project
|
||||
.id
|
||||
.ok_or_eyre("Project ID is missing in the project auth info")?,
|
||||
);
|
||||
} else {
|
||||
return Err(eyre!("Current project information can not be identified").into());
|
||||
}
|
||||
{%- elif v.remote_name == "user_id" %}
|
||||
{{ builder }}.{{ v.remote_name }}(
|
||||
client
|
||||
.get_auth_info()
|
||||
@@ -428,6 +461,7 @@ Some({{ val }})
|
||||
.user
|
||||
.id,
|
||||
);
|
||||
{%- endif %}
|
||||
}
|
||||
{%- endif %}
|
||||
{%- else %}
|
||||
|
||||
Reference in New Issue
Block a user