Repository navigation
Expand file tree
/
Copy pathSteampipe.session.sql
More file actions
200 lines (189 loc) · 4.52 KB
/
Copy pathSteampipe.session.sql
File metadata and controls
200 lines (189 loc) · 4.52 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---------------------------
-- Global account details
---------------------------
select
guid,
display_name,
created_date,
modified_date,
entity_state,
state_message,
subdomain,
contract_status,
commercial_model,
consumption_based
from
btp.btp_accounts_global_account;
---------------------------------
-- List all subaccounts in root
---------------------------------
select
guid,
display_name,
parent_guid,
parent_type,
subdomain,
custom_properties
from
btp_accounts_subaccount;
---------------------------------------
-- List all subaccounts in a directory
---------------------------------------
select
display_name,
region,
subdomain,
beta_enabled
from
btp_accounts_subaccount
where
parent_guid = '00643708-5865-4e15-a0b4-d276c3877502'
order by
region,
display_name;
---------------------------------
-- List all directories
---------------------------------
select distinct
parent_guid,
parent_type
from
btp_accounts_subaccount
where
parent_type = 'PROJECT';
---------------------------------
-- Count subaccounts by region
---------------------------------
select
region,
count(1)
from
btp_accounts_subaccount
group by
region
order by
count desc;
---------------------------------------------------
-- Subaccount details with datacenter information
---------------------------------------------------
select
sa.guid subaccount_guid,
sa.display_name subaccount_name,
sa.subdomain subaccount_subdomain,
dc.name dc_name,
dc.display_name as dc_location,
sa.region,
environment,
dc.iaas_provider,
supports_trial,
saas_registry_service_url,
domain,
geo_access
from
btp_accounts_subaccount sa
join
btp.btp_entitlements_datacenter dc
on sa.region = dc.region
order by
region,
subaccount_name;
----------------------------------------------
-- Get the business category of all services
----------------------------------------------
select distinct
business_category ->> 'id' bc_id
from
btp_entitlements_assignment bes;
---------------------------------------------------
-- Nested JSON structures in the Entitlements API
---------------------------------------------------
select
bes.display_name,
service_plans
from
btp_entitlements_assignment bes;
-------------------------------------------------------------
-- Assignments and quota for a particular business category
-------------------------------------------------------------
select
bes.display_name,
service_plan ->> 'name' sp_displayname,
service_plan ->> 'amount' sp_amount,
service_plan ->> 'remainingAmount' sp_remaining_amount
from
btp_entitlements_assignment bes
join
jsonb_array_elements(service_plans) service_plan
on true
where
business_category ->> 'id' = 'INTEGRATION'
order by
bes.display_name asc;
------------------------------------------------------------------
-- Assignments and the data centers where they are available
------------------------------------------------------------------
select
bes.name,
bes.display_name,
service_plan ->> 'name' sp_displayname,
data_centers ->> 'name' dc_name
from
btp_entitlements_assignment bes
join
jsonb_array_elements(service_plans) service_plan
on true
join
jsonb_array_elements(service_plan -> 'dataCenters') data_centers
on true
where
business_category ->> 'id' = 'AI'
and data_centers ->> 'name' = 'cf-eu10'
order by
bes.display_name asc;
select
bes.name,
bes.display_name,
service_plan ->> 'name' sp_displayname,
data_centers ->> 'name' dc_name
from
btp_entitlements_assignment bes
cross join
jsonb_array_elements(service_plans) service_plan
cross join
jsonb_array_elements(service_plan -> 'dataCenters') data_centers
where
business_category ->> 'id' = 'AI'
and data_centers ->> 'name' = 'cf-eu10'
order by
bes.display_name asc;
------------------------------------------------------------------
-- Have multiple BTP Global accounts?
------------------------------------------------------------------
select
glob.display_name "global account",
sub.region,
count(1)
from
btp.btp_accounts_subaccount sub
join
btp.btp_accounts_global_account glob
on sub.global_account_guid = glob.guid
group by
glob.display_name,
sub.region
union
select
glob.display_name "global account",
sub.region,
count(1)
from
btp_trial.btp_accounts_subaccount sub
join
btp_trial.btp_accounts_global_account glob
on sub.global_account_guid = glob.guid
group by
glob.display_name,
sub.region
order by
count desc,
region asc;