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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
macro_rules! credential_builder_base {
($name:ident) => {
impl $name {
pub fn with_client_id(&mut self, client_id: impl TryInto<uuid::Uuid>) -> &mut Self {
self.credential.app_config.with_client_id(client_id);
self
}
/// Convenience method. Same as calling [with_authority(Authority::TenantId("tenant_id"))]
pub fn with_tenant(&mut self, tenant_id: impl AsRef<str>) -> &mut Self {
self.credential.app_config.with_tenant(tenant_id);
self
}
pub fn with_authority(
&mut self,
authority: impl Into<crate::identity::Authority>,
) -> &mut Self {
self.credential.app_config.with_authority(authority.into());
self
}
pub fn with_azure_cloud_instance(
&mut self,
azure_cloud_instance: crate::identity::AzureCloudInstance,
) -> &mut Self {
self.credential
.app_config
.with_azure_cloud_instance(azure_cloud_instance);
self
}
/// Extends the query parameters of both the default query params and user defined params.
/// Does not overwrite default params.
pub fn with_extra_query_param(&mut self, query_param: (String, String)) -> &mut Self {
self.credential
.app_config
.with_extra_query_param(query_param);
self
}
/// Extends the query parameters of both the default query params and user defined params.
/// Does not overwrite default params.
pub fn with_extra_query_parameters(
&mut self,
query_parameters: HashMap<String, String>,
) -> &mut Self {
self.credential
.app_config
.with_extra_query_parameters(query_parameters);
self
}
/// Extends the header parameters of both the default header params and user defined params.
/// Does not overwrite default params.
pub fn with_extra_header_param<K: Into<HeaderName>, V: Into<HeaderValue>>(
&mut self,
header_name: K,
header_value: V,
) -> &mut Self {
self.credential
.app_config
.with_extra_header_param(header_name, header_value);
self
}
/// Extends the header parameters of both the default header params and user defined params.
/// Does not overwrite default params.
pub fn with_extra_header_parameters(
&mut self,
header_parameters: HeaderMap,
) -> &mut Self {
self.credential
.app_config
.with_extra_header_parameters(header_parameters);
self
}
pub fn with_scope<T: ToString, I: IntoIterator<Item = T>>(
&mut self,
scope: I,
) -> &mut Self {
self.credential.app_config.with_scope(scope);
self
}
pub fn with_config(
&mut self,
config: &graph_http::api_impl::GraphClientConfiguration,
) -> &mut Self {
self.credential.app_config.with_config(config.clone());
self
}
}
};
}
macro_rules! credential_builder {
($name:ident, $client:ty) => {
credential_builder_base!($name);
impl $name {
pub fn build(&self) -> $client {
<$client>::new(self.credential.clone())
}
}
};
}