Microsoft Information Protection (MIP) SDK for C++: Reference 1.16
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
cloud_discovery_delegate.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
27/**
28 * @brief Defines CouldDiscoveryDelegate interface
29 *
30 * @file cloud_discovery_delegate.h
31 */
32
33#ifndef API_MIP_CLOUD_DISCOVERY_DELEGATE_H_
34#define API_MIP_CLOUD_DISCOVERY_DELEGATE_H_
35
36#include <functional>
37#include <string>
38#include <vector>
39
40#include "mip/common_types.h"
41#include "mip/mip_namespace.h"
42
43MIP_NAMESPACE_BEGIN
44
45/**
46 * @brief Service information returned by cloud discovery
47 *
48 */
50public:
52 : mServiceType(ServiceType::Telemetry),
53 mUrl(""),
54 mResource(""),
55 mAuthority("") {
56 }
57
58 ServiceInfo(ServiceType serviceType, std::string url)
59 : ServiceInfo(serviceType, url, "", "") {
60 }
61
62 ServiceInfo(ServiceType serviceType, std::string url, std::string resource, std::string authority)
63 : mServiceType(serviceType),
64 mUrl(url),
65 mResource(resource),
66 mAuthority(authority) {
67 }
68
69 /**
70 * @brief Gets the service type of this ServiceInfo, like Protection, Policy, Telemetry, etc.
71 *
72 * @return service type
73 */
74 ServiceType GetServiceType() const { return mServiceType; }
75
76 /**
77 * @brief Gets the service URL like https://api.aadrm.com
78 *
79 * @return service URL
80 */
81 std::string GetUrl() const { return mUrl; }
82
83 /**
84 * @brief Gets the resource string for authentication
85 *
86 * @return resource string
87 */
88 std::string GetResource() const { return mResource; }
89
90 /**
91 * @brief Gets the authority string for authentication
92 *
93 * @return authority string
94 */
95 std::string GetAuthority() const { return mAuthority; }
96
97private:
98 ServiceType mServiceType;
99 std::string mUrl;
100 std::string mResource;
101 std::string mAuthority;
102};
103
104typedef std::vector<ServiceInfo> ServicesInfo;
105
106/**
107 * @brief Interface for the result of cloud discovery
108 */
110public:
111 /**
112 * @brief Get the services information #ServicesInfo
113 *
114 * @return a set of service information #ServicesInfo for the given domain info.
115 * Throws a #NetworkError if the cloud discovery service returned an invalid or unexpected response.
116 * Throws a #OperationCancelledError if the operation was cancelled.
117 * Throws a #Error if some other error is encountered.
118 */
119 virtual ServicesInfo GetServicesInfo() const = 0;
120
121 /**
122 * @brief detect if the given domain info is a sovereign cloud.
123 *
124 * @return true if the given domain info is a sovereign cloud, false otherwise.
125 * Throws a #NetworkError if the cloud discovery service returned an invalid or unexpected response.
126 * Throws a #OperationCancelledError if the operation was cancelled.
127 * Throws a #Error if some other error is encountered.
128 */
129 virtual bool IsSovereignCloud() const = 0;
130};
131
132/**
133* @brief Interface for overriding cloud discovery
134*/
136public:
137 /**
138 * @brief Get all services information for the given domain info
139 *
140 * @param domainInfo domain name or tenant Id.
141 * @param context opaque client context.
142 *
143 * @return a set of service information #ServicesInfo for the given domain info.
144 */
146 const std::string& domainInfo,
147 const std::shared_ptr<void>& context) = 0;
148
149 /**
150 * @brief Asynchronously get all services information for the given domain info.
151 *
152 * @param domainInfo domain name or tenant Id.
153 * @param context opaque client context.
154 * @param callbackFn Function that will be executed upon completion.
155 */
157 const std::string& domainInfo,
158 const std::shared_ptr<void>& context,
159 const std::function<void(const std::shared_ptr<CloudDiscoveryResult>& )>& callbackFn) = 0;
160
161 /**
162 * @brief Get all services information for the given cloud and data boundary.
163 *
164 * @param cloud Azure cloud identifier #Cloud.
165 * @param dataBoundary Diagnostic region identifier #DataBoundary.
166 * @param context opaque client context.
167 *
168 * @return a set of service information for the given cloud and data boundary.
169 */
171 const mip::Cloud cloud,
172 const mip::DataBoundary dataBoundary,
173 const std::shared_ptr<void>& context) = 0;
174
175 /**
176 * @brief Asynchronously get all services information for the given cloud and data boundary.
177 *
178 * @param cloud Azure cloud identifier #Cloud.
179 * @param dataBoundary Diagnostic region identifier #DataBoundary.
180 * @param context opaque client context.
181 * @param callbackFn Function that will be executed upon completion.
182 */
184 const mip::Cloud cloud,
185 const mip::DataBoundary dataBoundary,
186 const std::shared_ptr<void>& context,
187 const std::function<void(const std::shared_ptr<CloudDiscoveryResult>& )>& callbackFn) = 0;
188
189 /**
190 * @brief detect if the given domain info is a sovereign cloud.
191 *
192 * @param domainInfo domain name or tenant Id.
193 * @param context opaque client context.
194 *
195 * @return true if the given domain info is a sovereign cloud, false otherwise.
196 */
197 virtual bool IsSovereignCloud(
198 const std::string& domainInfo,
199 const std::shared_ptr<void>& context) = 0;
200
201 /**
202 * @brief Asynchronously detect if the given domain info is a sovereign cloud.
203 *
204 * @param domainInfo domain name or tenant Id.
205 * @param context opaque client context.
206 * @param callbackFn Function that will be executed upon completion.
207 */
209 const std::string& domainInfo,
210 const std::shared_ptr<void>& context,
211 const std::function<void(const std::shared_ptr<CloudDiscoveryResult>& )>& callbackFn) = 0;
212
213 /**
214 * @brief if this cloud discovery delegate is offline only.
215 *
216 * @return false if this cloud discovery delegate requires a network call, otherwise true.
217 */
218 virtual bool IsOffline() const = 0;
219
220/** @cond DOXYGEN_HIDE */
221
222 virtual ~CloudDiscoveryDelegate() {}
223
224protected:
226
227/** @endcond */
228};
229
230MIP_NAMESPACE_END
231#endif // API_MIP_CLOUD_DISCOVERY_DELEGATE_H_
232
Interface for overriding cloud discovery.
virtual bool IsOffline() const =0
if this cloud discovery delegate is offline only.
virtual void IsSovereignCloudAsync(const std::string &domainInfo, const std::shared_ptr< void > &context, const std::function< void(const std::shared_ptr< CloudDiscoveryResult > &)> &callbackFn)=0
Asynchronously detect if the given domain info is a sovereign cloud.
virtual ServicesInfo GetServicesInfo(const mip::Cloud cloud, const mip::DataBoundary dataBoundary, const std::shared_ptr< void > &context)=0
Get all services information for the given cloud and data boundary.
virtual void GetServicesInfoAsync(const std::string &domainInfo, const std::shared_ptr< void > &context, const std::function< void(const std::shared_ptr< CloudDiscoveryResult > &)> &callbackFn)=0
Asynchronously get all services information for the given domain info.
virtual ServicesInfo GetServicesInfo(const std::string &domainInfo, const std::shared_ptr< void > &context)=0
Get all services information for the given domain info.
virtual bool IsSovereignCloud(const std::string &domainInfo, const std::shared_ptr< void > &context)=0
detect if the given domain info is a sovereign cloud.
virtual void GetServicesInfoAsync(const mip::Cloud cloud, const mip::DataBoundary dataBoundary, const std::shared_ptr< void > &context, const std::function< void(const std::shared_ptr< CloudDiscoveryResult > &)> &callbackFn)=0
Asynchronously get all services information for the given cloud and data boundary.
Interface for the result of cloud discovery.
virtual bool IsSovereignCloud() const =0
detect if the given domain info is a sovereign cloud.
virtual ServicesInfo GetServicesInfo() const =0
Get the services information ServicesInfo.
Service information returned by cloud discovery.
ServiceInfo(ServiceType serviceType, std::string url, std::string resource, std::string authority)
std::string GetUrl() const
Gets the service URL like https://api.aadrm.com.
std::string GetAuthority() const
Gets the authority string for authentication.
ServiceType GetServiceType() const
Gets the service type of this ServiceInfo, like Protection, Policy, Telemetry, etc.
std::string GetResource() const
Gets the resource string for authentication.
ServiceInfo(ServiceType serviceType, std::string url)
std::vector< ServiceInfo > ServicesInfo
A file Containing the common types used by the upe, file and protection modules.
ServiceType
Service type identifier.
MIP namespace macros.