|
| 1 | +A resources on the CBWS platform are part of a project, they help bundle related resources for a specific goal. |
| 2 | + |
| 3 | +This guide describes how to create and use them to organize your resources. |
| 4 | + |
| 5 | +## Creating a project |
| 6 | + |
| 7 | +Creating projects requires the `Project creator` role on an organization, after creation you will get the |
| 8 | +`Project owner` role allowing to fully manage resources in the newly created project. |
| 9 | + |
| 10 | +!!! hint |
| 11 | + Since project names are unique across the entire CBWS platform it might be useful to for example prepend them |
| 12 | + with a abbreviation of your organization or product name. |
| 13 | + |
| 14 | +=== "Panel" |
| 15 | + 1. Click on the project selection button |
| 16 | + 2. Click on create project |
| 17 | + |
| 18 | +=== "CLI" |
| 19 | + ```bash |
| 20 | + cbws projects create test-project |
| 21 | + ``` |
| 22 | + |
| 23 | +=== "Golang" |
| 24 | + ```go |
| 25 | + package main |
| 26 | + |
| 27 | + import ( |
| 28 | + "context" |
| 29 | + "log" |
| 30 | + |
| 31 | + projects "github.com/cbws/go-cbws/cbws/projects/v1alpha1" |
| 32 | + |
| 33 | + ) |
| 34 | + func main() { |
| 35 | + p, err := projects.NewClient(context.Background()) |
| 36 | + if err != nil { |
| 37 | + log.Fatalf("Error: %+v", err) |
| 38 | + } |
| 39 | + |
| 40 | + project, err := p.CreateProject(context.Background(), "//organizations.cloudbear.nl/organizations/908e6132-1eb9-11ea-939b-9c81b2f6bed2", "test-project") |
| 41 | + if err != nil { |
| 42 | + log.Fatalf("Error: %+v", err) |
| 43 | + } |
| 44 | + |
| 45 | + log.Printf("Project: %+v", project) |
| 46 | + } |
| 47 | + ``` |
| 48 | + |
| 49 | +=== "PHP" |
| 50 | + ```php |
| 51 | + <?php |
| 52 | + $projects = new \Cbws\API\Projects\V1alpha1\Client(); |
| 53 | + $project = $projects->createProject('//organizations.cloudbear.nl/organizations/908e6132-1eb9-11ea-939b-9c81b2f6bed2', 'test-project'); |
| 54 | + ``` |
| 55 | + |
| 56 | +## Listing projects |
| 57 | + |
| 58 | +You generally have quite a few projects, listing all of them can be doing as follows: |
| 59 | + |
| 60 | +=== "Panel" |
| 61 | + |
| 62 | +=== "CLI" |
| 63 | + List all the projects you have access to, this will also include projects from organizations you've been given |
| 64 | + access to. |
| 65 | + |
| 66 | + ```bash |
| 67 | + cbws projects list |
| 68 | + ``` |
| 69 | + |
| 70 | +=== "Golang" |
| 71 | + This example uses the `PaginateProjects` helper method and the `Iterate` function of the CBWS pagination library |
| 72 | + to iterate through all the projects and handles pagination on the background. |
| 73 | + |
| 74 | + ```go |
| 75 | + package main |
| 76 | + |
| 77 | + import ( |
| 78 | + "context" |
| 79 | + "log" |
| 80 | + |
| 81 | + projects "github.com/cbws/go-cbws/cbws/projects/v1alpha1" |
| 82 | + |
| 83 | + ) |
| 84 | + func main() { |
| 85 | + p, err := projects.NewClient(context.Background()) |
| 86 | + if err != nil { |
| 87 | + log.Fatalf("Error: %+v", err) |
| 88 | + } |
| 89 | + |
| 90 | + paginator := p.PaginateProjects() |
| 91 | + edges, err := pagination.Iterate(context.Background(), paginator) |
| 92 | + if err != nil { |
| 93 | + log.Fatalf("Error: %+v", err) |
| 94 | + } |
| 95 | + |
| 96 | + for _, edge := range edges { |
| 97 | + log.Printf("Project: %+v", edge.Node) |
| 98 | + } |
| 99 | + } |
| 100 | + ``` |
| 101 | + |
| 102 | +=== "PHP" |
| 103 | + ```php |
| 104 | + <?php |
| 105 | + $projects = new \Cbws\API\Projects\V1alpha1\Client(); |
| 106 | + $data = $projects->listProjects(); |
| 107 | + foreach ($data->getProjects() as $project) { |
| 108 | + var_dump($project); |
| 109 | + } |
| 110 | + echo 'Next page token: ' . $data->getNextPageToken() . PHP_EOL; |
| 111 | + ``` |
| 112 | + |
| 113 | +## Using a project |
| 114 | + |
| 115 | +Most things you do on the CBWS platform will be done in the context of a project. Most tools will work in a specific |
| 116 | +project so you can focus on the things at hand. It is however very easy to switch back and forth between different |
| 117 | +projects. |
| 118 | + |
| 119 | +=== "Panel" |
| 120 | + |
| 121 | + When you open the CBWS panel you can select a project by using the project selection button in the menu on the left. |
| 122 | + |
| 123 | +=== "CLI" |
| 124 | + The CBWS command line tool generally operates on a specific project. This way you only see and manage the resources |
| 125 | + related to that specific project. Switching between projects can be done using the following command: |
| 126 | + |
| 127 | + ```bash |
| 128 | + cbws projects use test-project |
| 129 | + ``` |
| 130 | + |
| 131 | + You can also use a flag to run a specfic command on a different project: |
| 132 | + |
| 133 | + ```bash |
| 134 | + cbws -p test-project iam service-accounts list |
| 135 | + ``` |
| 136 | + |
| 137 | +## Project IAM policies |
| 138 | + |
| 139 | +When creating a new project, you will be the only one with the `Project owner` role. This will give you full access to |
| 140 | +all resources within the project, and full access to the project itself. To give others or service accounts access to |
| 141 | +your project or create a more specific access policy you can use the project IAM policies. |
| 142 | + |
| 143 | +For more details IAM policies you can read the IAM getting started documentation. |
| 144 | + |
| 145 | +!!! info |
| 146 | + To ensure we can help you we by default also give `Cloudbear tech support` the `Tech support` role on your project. |
| 147 | + You can remove this at any point, this does mean our support department won't be able to immediately help you. |
| 148 | + |
| 149 | +### Getting current policy |
| 150 | + |
| 151 | +### Changing policy |
| 152 | + |
| 153 | +!!! warning |
| 154 | + Giving a principal the `setIAMPOlicy` permission will also this principal to give themselves more access. |
0 commit comments