Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra-proxy-service] Add Environments gRPC & HTTP API #2985

Merged
merged 3 commits into from
Mar 22, 2020

Conversation

kvivek1115
Copy link

@kvivek1115 kvivek1115 commented Feb 28, 2020

🔩 Description: What code changed, and why?

  • Add infra environment list API with attributes name.

gRPC API:

chef-automate dev grpcurl infra-proxy-service chef.automate.domain.infra_proxy.service.InfraProxy.GetEnvironments -- -d '{"org_id": "8f1646d3-35ae-4562-84d7-ff013f3973f2", "server_id": "c7d36e02-4816-4bfa-a1b9-d239f56c9b8d"}'

HTTP API:

curl -sSkH "api-token: $TOK" https://a2-dev.test/api/v0/infra/servers/{server_id}/orgs/{org_id}/environments

Response format:

{
  "environments": [
    {
      "name": "_default"
    },
  ]
}
  • Add infra environment detail API with attributes name, chef_type, description, run_list, json_class

gRPC API:

chef-automate dev grpcurl infra-proxy-service chef.automate.domain.infra_proxy.service.InfraProxy.GetEnvironment -- -d '{"org_id": "8f1646d3-35ae-4562-84d7-ff013f3973f2", "server_id": "c7d36e02-4816-4bfa-a1b9-d239f56c9b8d", "name": "_default"}'

HTTP API:

curl -sSkH "api-token: $TOK" https://a2-dev.test/api/v0/infra/servers/{server_id}/orgs/{org_id}/environments/name

Response format:

{
  "name": "_default",
  "chefType": "environment",
  "description": "The default Chef environment",
  "jsonClass": "Chef::Environment"
}

⛓️ Related Resources

#1544

👍 Definition of Done

  • Able to access environments list and detail API

👟 How to Build and Test the Change

  • rebuild components/infra-proxy-service
  • rebuild components/automate-gateway

In order to test these features, we can try to curl command to test the API describes in the description.

✅ Checklist

📷 Screenshots, if applicable

Signed-off-by: Vivek Singh [email protected]

@kvivek1115 kvivek1115 self-assigned this Feb 28, 2020
@kvivek1115 kvivek1115 force-pushed the VSingh/infra-proxy-service-environments-api branch from b5e8811 to e3ea212 Compare March 11, 2020 16:09
return nil, status.Error(codes.InvalidArgument, err.Error())
}

defaultAttributes, _ := json.Marshal(en.DefaultAttributes)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specific data type to hold DefaultAttributes data?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took the reference from NodeAttribute for dynamic attributes as:

// Stringified json of the normal attributes for the node.
string normal = 5;
// Stringified json of the default attributes for the node.
string default = 6;
// Stringified json of the override attributes for the node.
string override = 7;
// Stringified json of the automatic attributes for the node.
string automatic = 13;

@kvivek1115 kvivek1115 force-pushed the VSingh/infra-proxy-service-environments-api branch from e3ea212 to a9e8431 Compare March 19, 2020 08:34
@kvivek1115 kvivek1115 changed the title [WIP][infra-proxy-service] Add Environments gRPC & HTTP API [infra-proxy-service] Add Environments gRPC & HTTP API Mar 19, 2020
@kvivek1115 kvivek1115 requested a review from vjeffrey March 19, 2020 14:50
string org_id = 1;
// Id of the Server.
string server_id = 2;
// Name of the environment.
Copy link

@vjeffrey vjeffrey Mar 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for including the descriptions of the fields!! (the proto comments)

}

defaultAttributes, _ := json.Marshal(en.DefaultAttributes)
overrideAttributes, _ := json.Marshal(en.OverrideAttributes)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err check? same comment for a couple lines up too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure @vjeffrey thanks for pointing it out!

@vjeffrey vjeffrey merged commit aa1a179 into master Mar 22, 2020
@chef-expeditor chef-expeditor bot deleted the VSingh/infra-proxy-service-environments-api branch March 22, 2020 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants