You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

392 rivejä
7.8 KiB

  1. // Copyright 2019 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Code generated by gapic-generator. DO NOT EDIT.
  15. package securitycenter_test
  16. import (
  17. "context"
  18. securitycenter "cloud.google.com/go/securitycenter/apiv1"
  19. "google.golang.org/api/iterator"
  20. securitycenterpb "google.golang.org/genproto/googleapis/cloud/securitycenter/v1"
  21. iampb "google.golang.org/genproto/googleapis/iam/v1"
  22. )
  23. func ExampleNewClient() {
  24. ctx := context.Background()
  25. c, err := securitycenter.NewClient(ctx)
  26. if err != nil {
  27. // TODO: Handle error.
  28. }
  29. // TODO: Use client.
  30. _ = c
  31. }
  32. func ExampleClient_CreateSource() {
  33. ctx := context.Background()
  34. c, err := securitycenter.NewClient(ctx)
  35. if err != nil {
  36. // TODO: Handle error.
  37. }
  38. req := &securitycenterpb.CreateSourceRequest{
  39. // TODO: Fill request struct fields.
  40. }
  41. resp, err := c.CreateSource(ctx, req)
  42. if err != nil {
  43. // TODO: Handle error.
  44. }
  45. // TODO: Use resp.
  46. _ = resp
  47. }
  48. func ExampleClient_CreateFinding() {
  49. ctx := context.Background()
  50. c, err := securitycenter.NewClient(ctx)
  51. if err != nil {
  52. // TODO: Handle error.
  53. }
  54. req := &securitycenterpb.CreateFindingRequest{
  55. // TODO: Fill request struct fields.
  56. }
  57. resp, err := c.CreateFinding(ctx, req)
  58. if err != nil {
  59. // TODO: Handle error.
  60. }
  61. // TODO: Use resp.
  62. _ = resp
  63. }
  64. func ExampleClient_GetIamPolicy() {
  65. ctx := context.Background()
  66. c, err := securitycenter.NewClient(ctx)
  67. if err != nil {
  68. // TODO: Handle error.
  69. }
  70. req := &iampb.GetIamPolicyRequest{
  71. // TODO: Fill request struct fields.
  72. }
  73. resp, err := c.GetIamPolicy(ctx, req)
  74. if err != nil {
  75. // TODO: Handle error.
  76. }
  77. // TODO: Use resp.
  78. _ = resp
  79. }
  80. func ExampleClient_GetOrganizationSettings() {
  81. ctx := context.Background()
  82. c, err := securitycenter.NewClient(ctx)
  83. if err != nil {
  84. // TODO: Handle error.
  85. }
  86. req := &securitycenterpb.GetOrganizationSettingsRequest{
  87. // TODO: Fill request struct fields.
  88. }
  89. resp, err := c.GetOrganizationSettings(ctx, req)
  90. if err != nil {
  91. // TODO: Handle error.
  92. }
  93. // TODO: Use resp.
  94. _ = resp
  95. }
  96. func ExampleClient_GetSource() {
  97. ctx := context.Background()
  98. c, err := securitycenter.NewClient(ctx)
  99. if err != nil {
  100. // TODO: Handle error.
  101. }
  102. req := &securitycenterpb.GetSourceRequest{
  103. // TODO: Fill request struct fields.
  104. }
  105. resp, err := c.GetSource(ctx, req)
  106. if err != nil {
  107. // TODO: Handle error.
  108. }
  109. // TODO: Use resp.
  110. _ = resp
  111. }
  112. func ExampleClient_GroupAssets() {
  113. ctx := context.Background()
  114. c, err := securitycenter.NewClient(ctx)
  115. if err != nil {
  116. // TODO: Handle error.
  117. }
  118. req := &securitycenterpb.GroupAssetsRequest{
  119. // TODO: Fill request struct fields.
  120. }
  121. it := c.GroupAssets(ctx, req)
  122. for {
  123. resp, err := it.Next()
  124. if err == iterator.Done {
  125. break
  126. }
  127. if err != nil {
  128. // TODO: Handle error.
  129. }
  130. // TODO: Use resp.
  131. _ = resp
  132. }
  133. }
  134. func ExampleClient_GroupFindings() {
  135. ctx := context.Background()
  136. c, err := securitycenter.NewClient(ctx)
  137. if err != nil {
  138. // TODO: Handle error.
  139. }
  140. req := &securitycenterpb.GroupFindingsRequest{
  141. // TODO: Fill request struct fields.
  142. }
  143. it := c.GroupFindings(ctx, req)
  144. for {
  145. resp, err := it.Next()
  146. if err == iterator.Done {
  147. break
  148. }
  149. if err != nil {
  150. // TODO: Handle error.
  151. }
  152. // TODO: Use resp.
  153. _ = resp
  154. }
  155. }
  156. func ExampleClient_ListAssets() {
  157. ctx := context.Background()
  158. c, err := securitycenter.NewClient(ctx)
  159. if err != nil {
  160. // TODO: Handle error.
  161. }
  162. req := &securitycenterpb.ListAssetsRequest{
  163. // TODO: Fill request struct fields.
  164. }
  165. it := c.ListAssets(ctx, req)
  166. for {
  167. resp, err := it.Next()
  168. if err == iterator.Done {
  169. break
  170. }
  171. if err != nil {
  172. // TODO: Handle error.
  173. }
  174. // TODO: Use resp.
  175. _ = resp
  176. }
  177. }
  178. func ExampleClient_ListFindings() {
  179. ctx := context.Background()
  180. c, err := securitycenter.NewClient(ctx)
  181. if err != nil {
  182. // TODO: Handle error.
  183. }
  184. req := &securitycenterpb.ListFindingsRequest{
  185. // TODO: Fill request struct fields.
  186. }
  187. it := c.ListFindings(ctx, req)
  188. for {
  189. resp, err := it.Next()
  190. if err == iterator.Done {
  191. break
  192. }
  193. if err != nil {
  194. // TODO: Handle error.
  195. }
  196. // TODO: Use resp.
  197. _ = resp
  198. }
  199. }
  200. func ExampleClient_ListSources() {
  201. ctx := context.Background()
  202. c, err := securitycenter.NewClient(ctx)
  203. if err != nil {
  204. // TODO: Handle error.
  205. }
  206. req := &securitycenterpb.ListSourcesRequest{
  207. // TODO: Fill request struct fields.
  208. }
  209. it := c.ListSources(ctx, req)
  210. for {
  211. resp, err := it.Next()
  212. if err == iterator.Done {
  213. break
  214. }
  215. if err != nil {
  216. // TODO: Handle error.
  217. }
  218. // TODO: Use resp.
  219. _ = resp
  220. }
  221. }
  222. func ExampleClient_RunAssetDiscovery() {
  223. ctx := context.Background()
  224. c, err := securitycenter.NewClient(ctx)
  225. if err != nil {
  226. // TODO: Handle error.
  227. }
  228. req := &securitycenterpb.RunAssetDiscoveryRequest{
  229. // TODO: Fill request struct fields.
  230. }
  231. op, err := c.RunAssetDiscovery(ctx, req)
  232. if err != nil {
  233. // TODO: Handle error.
  234. }
  235. err = op.Wait(ctx)
  236. // TODO: Handle error.
  237. }
  238. func ExampleClient_SetFindingState() {
  239. ctx := context.Background()
  240. c, err := securitycenter.NewClient(ctx)
  241. if err != nil {
  242. // TODO: Handle error.
  243. }
  244. req := &securitycenterpb.SetFindingStateRequest{
  245. // TODO: Fill request struct fields.
  246. }
  247. resp, err := c.SetFindingState(ctx, req)
  248. if err != nil {
  249. // TODO: Handle error.
  250. }
  251. // TODO: Use resp.
  252. _ = resp
  253. }
  254. func ExampleClient_SetIamPolicy() {
  255. ctx := context.Background()
  256. c, err := securitycenter.NewClient(ctx)
  257. if err != nil {
  258. // TODO: Handle error.
  259. }
  260. req := &iampb.SetIamPolicyRequest{
  261. // TODO: Fill request struct fields.
  262. }
  263. resp, err := c.SetIamPolicy(ctx, req)
  264. if err != nil {
  265. // TODO: Handle error.
  266. }
  267. // TODO: Use resp.
  268. _ = resp
  269. }
  270. func ExampleClient_TestIamPermissions() {
  271. ctx := context.Background()
  272. c, err := securitycenter.NewClient(ctx)
  273. if err != nil {
  274. // TODO: Handle error.
  275. }
  276. req := &iampb.TestIamPermissionsRequest{
  277. // TODO: Fill request struct fields.
  278. }
  279. resp, err := c.TestIamPermissions(ctx, req)
  280. if err != nil {
  281. // TODO: Handle error.
  282. }
  283. // TODO: Use resp.
  284. _ = resp
  285. }
  286. func ExampleClient_UpdateFinding() {
  287. ctx := context.Background()
  288. c, err := securitycenter.NewClient(ctx)
  289. if err != nil {
  290. // TODO: Handle error.
  291. }
  292. req := &securitycenterpb.UpdateFindingRequest{
  293. // TODO: Fill request struct fields.
  294. }
  295. resp, err := c.UpdateFinding(ctx, req)
  296. if err != nil {
  297. // TODO: Handle error.
  298. }
  299. // TODO: Use resp.
  300. _ = resp
  301. }
  302. func ExampleClient_UpdateOrganizationSettings() {
  303. ctx := context.Background()
  304. c, err := securitycenter.NewClient(ctx)
  305. if err != nil {
  306. // TODO: Handle error.
  307. }
  308. req := &securitycenterpb.UpdateOrganizationSettingsRequest{
  309. // TODO: Fill request struct fields.
  310. }
  311. resp, err := c.UpdateOrganizationSettings(ctx, req)
  312. if err != nil {
  313. // TODO: Handle error.
  314. }
  315. // TODO: Use resp.
  316. _ = resp
  317. }
  318. func ExampleClient_UpdateSource() {
  319. ctx := context.Background()
  320. c, err := securitycenter.NewClient(ctx)
  321. if err != nil {
  322. // TODO: Handle error.
  323. }
  324. req := &securitycenterpb.UpdateSourceRequest{
  325. // TODO: Fill request struct fields.
  326. }
  327. resp, err := c.UpdateSource(ctx, req)
  328. if err != nil {
  329. // TODO: Handle error.
  330. }
  331. // TODO: Use resp.
  332. _ = resp
  333. }
  334. func ExampleClient_UpdateSecurityMarks() {
  335. ctx := context.Background()
  336. c, err := securitycenter.NewClient(ctx)
  337. if err != nil {
  338. // TODO: Handle error.
  339. }
  340. req := &securitycenterpb.UpdateSecurityMarksRequest{
  341. // TODO: Fill request struct fields.
  342. }
  343. resp, err := c.UpdateSecurityMarks(ctx, req)
  344. if err != nil {
  345. // TODO: Handle error.
  346. }
  347. // TODO: Use resp.
  348. _ = resp
  349. }