aboutsummaryrefslogtreecommitdiffstats
path: root/ms/py-executor/resource_resolution/README
blob: a2d1542abcbd8a4bfe72b60b297a0b5fad2fef7d (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
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
# Resource resolution client

##  How to use examples

### Insecure channel

```
from blueprints_grpc.proto.BluePrintCommon_pb2_grpc import ActionIdentifiers, CommonHeader
from blueprints_grpc.proto.BluePrintProcessing_pb2_grpc import ExecutionServiceInput
from resource_resolution.client import Client as ResourceResolutionClient


def generate_messages():
    commonHeader = CommonHeader()
    commonHeader.requestId = "1234"
    commonHeader.subRequestId = "1234-1"
    commonHeader.originatorId = "CDS"

    actionIdentifiers = ActionIdentifiers()
    actionIdentifiers.blueprintName = "sample-cba"
    actionIdentifiers.blueprintVersion = "1.0.0"
    actionIdentifiers.actionName = "SampleScript"

    input = ExecutionServiceInput(commonHeader=commonHeader, actionIdentifiers=actionIdentifiers)

    commonHeader2 = CommonHeader()
    commonHeader2.requestId = "1235"
    commonHeader2.subRequestId = "1234-2"
    commonHeader2.originatorId = "CDS"

    input2 = ExecutionServiceInput(commonHeader=commonHeader2, actionIdentifiers=actionIdentifiers)

    yield from [input, input2]


if __name__ == "__main__":
    with ResourceResolutionClient("localhost:50052") as client:
        for response in client.process(generate_messages()):
            print(response)

```

### Secure channel

```
from blueprints_grpc.proto.BluePrintCommon_pb2_grpc import ActionIdentifiers, CommonHeader
from blueprints_grpc.proto.BluePrintProcessing_pb2_grpc import ExecutionServiceInput
from resource_resolution.client import Client as ResourceResolutionClient


def generate_messages():
    commonHeader = CommonHeader()
    commonHeader.requestId = "1234"
    commonHeader.subRequestId = "1234-1"
    commonHeader.originatorId = "CDS"

    actionIdentifiers = ActionIdentifiers()
    actionIdentifiers.blueprintName = "sample-cba"
    actionIdentifiers.blueprintVersion = "1.0.0"
    actionIdentifiers.actionName = "SampleScript"

    input = ExecutionServiceInput(commonHeader=commonHeader, actionIdentifiers=actionIdentifiers)

    commonHeader2 = CommonHeader()
    commonHeader2.requestId = "1235"
    commonHeader2.subRequestId = "1234-2"
    commonHeader2.originatorId = "CDS"

    input2 = ExecutionServiceInput(commonHeader=commonHeader2, actionIdentifiers=actionIdentifiers)

    yield from [input, input2]


if __name__ == "__main__":
    with open("certs/py-executor/py-executor-chain.pem", "rb") as f:
        with ResourceResolutionClient("localhost:50052", use_ssl=True, root_certificates=f.read()) as client:
            for response in client.process(generate_messages()):
                print(response)

```