Statistics
| Branch: | Tag: | Revision:

root / src / main / avro / aquarium-user-state.avdl @ 4b8ff3e0

History | View | Annotate | Download (5.3 kB)

1 57d4eb82 Christos KK Loverdos
/*
2 57d4eb82 Christos KK Loverdos
 * Copyright 2011-2012 GRNET S.A. All rights reserved.
3 57d4eb82 Christos KK Loverdos
 *
4 57d4eb82 Christos KK Loverdos
 * Redistribution and use in source and binary forms, with or
5 57d4eb82 Christos KK Loverdos
 * without modification, are permitted provided that the following
6 57d4eb82 Christos KK Loverdos
 * conditions are met:
7 57d4eb82 Christos KK Loverdos
 *
8 57d4eb82 Christos KK Loverdos
 *   1. Redistributions of source code must retain the above
9 57d4eb82 Christos KK Loverdos
 *      copyright notice, this list of conditions and the following
10 57d4eb82 Christos KK Loverdos
 *      disclaimer.
11 57d4eb82 Christos KK Loverdos
 *
12 57d4eb82 Christos KK Loverdos
 *   2. Redistributions in binary form must reproduce the above
13 57d4eb82 Christos KK Loverdos
 *      copyright notice, this list of conditions and the following
14 57d4eb82 Christos KK Loverdos
 *      disclaimer in the documentation and/or other materials
15 57d4eb82 Christos KK Loverdos
 *      provided with the distribution.
16 57d4eb82 Christos KK Loverdos
 *
17 57d4eb82 Christos KK Loverdos
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 57d4eb82 Christos KK Loverdos
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 57d4eb82 Christos KK Loverdos
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 57d4eb82 Christos KK Loverdos
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 57d4eb82 Christos KK Loverdos
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 57d4eb82 Christos KK Loverdos
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 57d4eb82 Christos KK Loverdos
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 57d4eb82 Christos KK Loverdos
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 57d4eb82 Christos KK Loverdos
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 57d4eb82 Christos KK Loverdos
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 57d4eb82 Christos KK Loverdos
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 57d4eb82 Christos KK Loverdos
 * POSSIBILITY OF SUCH DAMAGE.
29 57d4eb82 Christos KK Loverdos
 *
30 57d4eb82 Christos KK Loverdos
 * The views and conclusions contained in the software and
31 57d4eb82 Christos KK Loverdos
 * documentation are those of the authors and should not be
32 57d4eb82 Christos KK Loverdos
 * interpreted as representing official policies, either expressed
33 57d4eb82 Christos KK Loverdos
 * or implied, of GRNET S.A.
34 57d4eb82 Christos KK Loverdos
 */
35 57d4eb82 Christos KK Loverdos
36 57d4eb82 Christos KK Loverdos
@namespace("gr.grnet.aquarium.message.avro.gen")
37 57d4eb82 Christos KK Loverdos
protocol AquariumUserState {
38 0c3fe597 Christos KK Loverdos
  import idl "aquarium-policy.avdl";
39 57d4eb82 Christos KK Loverdos
  import idl "aquarium-anyvalue.avdl";
40 57d4eb82 Christos KK Loverdos
  import idl "aquarium-events.avdl";
41 57d4eb82 Christos KK Loverdos
42 bbd79cea Christos KK Loverdos
  record UserAgreementMsg {
43 57d4eb82 Christos KK Loverdos
    string id;
44 55c8d76f Christos KK Loverdos
    union {string, null} relatedIMEventOriginalID;
45 55c8d76f Christos KK Loverdos
    string userID;
46 335e13ba Christos KK Loverdos
    long occurredMillis = 0; // when was this agreement created inside Aquarium
47 57d4eb82 Christos KK Loverdos
    long @order("ascending") validFromMillis;
48 57d4eb82 Christos KK Loverdos
    long validToMillis;
49 57d4eb82 Christos KK Loverdos
    string role;
50 bbd79cea Christos KK Loverdos
    union {FullPriceTableMsg, null} fullPriceTableRef; // If null, then get from aquarium policy
51 335e13ba Christos KK Loverdos
    union {IMEventMsg, null} relatedIMEventMsg; // non-null if there is a related IMEvent
52 57d4eb82 Christos KK Loverdos
  }
53 57d4eb82 Christos KK Loverdos
54 55c8d76f Christos KK Loverdos
  record ResourceInstanceChargingStateMsg {
55 55c8d76f Christos KK Loverdos
    string clientID; // who sent me?
56 55c8d76f Christos KK Loverdos
    string resource; // what kind of resource am I?
57 55c8d76f Christos KK Loverdos
    string instanceID; // who am I?
58 bbd79cea Christos KK Loverdos
    map<AnyValueMsg> details;
59 bbd79cea Christos KK Loverdos
    array<ResourceEventMsg> previousEvents;
60 bbd79cea Christos KK Loverdos
    array<ResourceEventMsg> implicitlyIssuedStartEvents;
61 60b17b9a Christos KK Loverdos
   string accumulatingAmount;
62 60b17b9a Christos KK Loverdos
   string oldAccumulatingAmount;
63 60b17b9a Christos KK Loverdos
   string previousValue;
64 60b17b9a Christos KK Loverdos
   string currentValue;
65 57d4eb82 Christos KK Loverdos
  }
66 57d4eb82 Christos KK Loverdos
67 55c8d76f Christos KK Loverdos
  record ResourcesChargingStateMsg {
68 55c8d76f Christos KK Loverdos
    string resource; // who am I?
69 bbd79cea Christos KK Loverdos
    map<AnyValueMsg> details;
70 55c8d76f Christos KK Loverdos
    map<ResourceInstanceChargingStateMsg> stateOfResourceInstance;
71 57d4eb82 Christos KK Loverdos
  }
72 57d4eb82 Christos KK Loverdos
73 55c8d76f Christos KK Loverdos
  record UserAgreementHistoryMsg {
74 335e13ba Christos KK Loverdos
    string originalID;
75 335e13ba Christos KK Loverdos
    union {string, null} inStoreID;
76 335e13ba Christos KK Loverdos
    string userID;
77 335e13ba Christos KK Loverdos
    long latestOccurredMillis; // the latest occurredMillis of all underlying agreements
78 335e13ba Christos KK Loverdos
    long latestValidFromMillis; // the latest validFromMillis of all underlying agreements
79 d7f5340d Christos KK Loverdos
    long userCreationTimeMillis = 0;
80 bbd79cea Christos KK Loverdos
    array<UserAgreementMsg> agreements;
81 57d4eb82 Christos KK Loverdos
  }
82 57d4eb82 Christos KK Loverdos
83 bbd79cea Christos KK Loverdos
  record ChargeslotMsg {
84 57d4eb82 Christos KK Loverdos
    long startMillis;
85 57d4eb82 Christos KK Loverdos
    long stopMillis;
86 4b8ff3e0 Christos KK Loverdos
    string unitPrice;
87 57d4eb82 Christos KK Loverdos
    string explanation = "";
88 4b8ff3e0 Christos KK Loverdos
    string creditsToSubtract = 0.0;
89 57d4eb82 Christos KK Loverdos
  }
90 57d4eb82 Christos KK Loverdos
91 55c8d76f Christos KK Loverdos
  // The following equation must hold (within a very small error):
92 55c8d76f Christos KK Loverdos
  //   `newTotalCredits = oldTotalCredits - sumOfCreditsToSubtract`.
93 bbd79cea Christos KK Loverdos
  record WalletEntryMsg {
94 55c8d76f Christos KK Loverdos
    string userID; // The user ID this wallet entry is related to.
95 60b17b9a Christos KK Loverdos
    string sumOfCreditsToSubtract; // The credit amount generated for this wallet entry.
96 60b17b9a Christos KK Loverdos
    string oldTotalCredits;
97 60b17b9a Christos KK Loverdos
    string newTotalCredits;
98 e5369e9d Christos KK Loverdos
    long whenComputedMillis;   // When the computation took place
99 e5369e9d Christos KK Loverdos
    long referenceStartMillis; // start of period this entry refers to
100 e5369e9d Christos KK Loverdos
    long referenceStopMillis;  // end of period this entry refers to
101 57d4eb82 Christos KK Loverdos
    int billingYear;
102 57d4eb82 Christos KK Loverdos
    int billingMonth;
103 55c8d76f Christos KK Loverdos
    int billingMonthDay;
104 55c8d76f Christos KK Loverdos
    array<ChargeslotMsg> chargeslots; // The details of the credit computation
105 e5369e9d Christos KK Loverdos
    array<ResourceEventMsg> resourceEvents; // The events used to make this computation. The current is the last one
106 bbd79cea Christos KK Loverdos
    ResourceTypeMsg resourceType;
107 57d4eb82 Christos KK Loverdos
    boolean isSynthetic = false;
108 e5369e9d Christos KK Loverdos
    boolean isForRealtimeCalc = false;
109 57d4eb82 Christos KK Loverdos
  }
110 57d4eb82 Christos KK Loverdos
111 55c8d76f Christos KK Loverdos
  // convenient wrapper for a list of wallet entries
112 55c8d76f Christos KK Loverdos
  record WalletEntriesMsg {
113 55c8d76f Christos KK Loverdos
    array<WalletEntryMsg> entries;
114 55c8d76f Christos KK Loverdos
  }
115 55c8d76f Christos KK Loverdos
116 55c8d76f Christos KK Loverdos
  record UserStateMsg {
117 335e13ba Christos KK Loverdos
    string originalID; // internal Aquarium ID
118 335e13ba Christos KK Loverdos
    union {string, null} inStoreID; // From Aquarium store
119 57d4eb82 Christos KK Loverdos
    string userID;
120 55c8d76f Christos KK Loverdos
    long occurredMillis; // When we created the event
121 55c8d76f Christos KK Loverdos
    union {string, null} parentOriginalID;
122 55c8d76f Christos KK Loverdos
    union {string, null} parentInStoreID;
123 60b17b9a Christos KK Loverdos
    boolean isFirst = false; // True only for the very first user state
124 e5369e9d Christos KK Loverdos
    boolean isForFullMonth = false; // True when computed as a reference for a month's billing state
125 335e13ba Christos KK Loverdos
    map<ResourcesChargingStateMsg> stateOfResources; // Map[ResourceTypeMsg.name.type, ]
126 b71ac54f Christos KK Loverdos
    string totalCredits = "0";
127 55c8d76f Christos KK Loverdos
    long latestUpdateMillis; // // last update of this working user state
128 57d4eb82 Christos KK Loverdos
    long latestResourceEventOccurredMillis;
129 55c8d76f Christos KK Loverdos
    long billingPeriodOutOfSyncResourceEventsCounter = 0;
130 e5369e9d Christos KK Loverdos
    int billingYear; // The billing year this snapshot refers to
131 e5369e9d Christos KK Loverdos
    int billingMonth; //  The billing month this year refers to
132 55c8d76f Christos KK Loverdos
    int billingMonthDay;
133 e5369e9d Christos KK Loverdos
    UserAgreementHistoryMsg userAgreementHistory;
134 bbd79cea Christos KK Loverdos
    array<WalletEntryMsg> walletEntries;
135 57d4eb82 Christos KK Loverdos
  }
136 57d4eb82 Christos KK Loverdos
}