summaryrefslogtreecommitdiffstats
path: root/examples/cpp/Identify.cpp
blob: dabca15f87fa0b5fb5a9272bd5fb28b54b53365d (plain)
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
#include <iostream>
#include <cpp/OpenWsmanClient.h>
#include <u/libu.h>

using std::cout;

using namespace WsmanClientNamespace;
int main(int argc, char* argv[])
{
	const char *endpoint, *resource_uri;
	string out;
	u_uri_t *uri;
	if (argc< 2) {
		fprintf(stderr, "Usage: %s <endpoint>\n", argv[0]);
	}
	endpoint= argv[1];

	if (!endpoint) {
		fprintf(stderr, "endpoint option required\n");
		return 1;
	}
	if (endpoint != NULL)
		if (u_uri_parse((const char *) endpoint, &uri) != 0 )
			return 1;
	OpenWsmanClient *client = new OpenWsmanClient( uri->host,
			uri->port,
			uri->path,
			uri->scheme,
			"digest",
			uri->user,
			uri->pwd);
	try {
		out = client->Identify();
	}

	catch (GeneralWsmanException &e) {
		printf("GeneralWsmanException:\n");
		printf("%s\n", e.what());

	}
	cout << "Identify: " << out << "\n";
	return 0;
}