Class: BitwardenSDKSecrets::ProjectsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/projects.rb

Instance Method Summary collapse

Constructor Details

#initialize(command_runner) ⇒ ProjectsClient

Returns a new instance of ProjectsClient.



7
8
9
# File 'lib/projects.rb', line 7

def initialize(command_runner)
  @command_runner = command_runner
end

Instance Method Details

#create(organization_id, project_name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/projects.rb', line 11

def create(organization_id, project_name)
  project_create_request = ProjectCreateRequest.new(
    project_create_request_name: project_name,
    organization_id: organization_id
  )
  command = create_command(
    create: project_create_request
  )
  response = parse_response(command)

  projects_response = ResponseForProjectResponse.from_json!(response).to_dynamic

  if projects_response.key?('success') && projects_response['success'] == true &&
    projects_response.key?('data')
    return projects_response['data']
  end

  error_response(projects_response)
end

#delete(ids) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/projects.rb', line 82

def delete(ids)
  project_delete_request = ProjectsDeleteRequest.new(ids: ids)
  command = create_command(delete: project_delete_request)
  response = parse_response(command)

  projects_response = ResponseForProjectsDeleteResponse.from_json!(response).to_dynamic

  if projects_response.key?('success') && projects_response['success'] == true &&
     projects_response.key?('data') && projects_response['data'].key?('data')
    return projects_response['data']['data']
  end

  error_response(projects_response)
end

#get(project_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/projects.rb', line 31

def get(project_id)
  project_get_request = ProjectGetRequest.new(id: project_id)
  command = create_command(get: project_get_request)
  response = parse_response(command)

  projects_response = ResponseForProjectResponse.from_json!(response).to_dynamic

  if projects_response.key?('success') && projects_response['success'] == true &&
    projects_response.key?('data')
    return projects_response['data']
  end

  error_response(projects_response)
end

#list(organization_id) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/projects.rb', line 46

def list(organization_id)
  project_list_request = ProjectsListRequest.new(organization_id: organization_id)
  command = create_command(list: project_list_request)
  response = parse_response(command)

  projects_response = ResponseForProjectsResponse.from_json!(response).to_dynamic

  if projects_response.key?('success') && projects_response['success'] == true &&
     projects_response.key?('data') && projects_response['data'].key?('data')
    return projects_response['data']['data']
  end

  error_response(projects_response)
end

#update(organization_id, id, project_put_request_name) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/projects.rb', line 61

def update(organization_id, id, project_put_request_name)
  project_put_request = ProjectPutRequest.new(
    id: id,
    project_put_request_name: project_put_request_name,
    organization_id: organization_id
  )
  command = create_command(
    update: project_put_request
  )
  response = parse_response(command)

  projects_response = ResponseForProjectResponse.from_json!(response).to_dynamic

  if projects_response.key?('success') && projects_response['success'] == true &&
     projects_response.key?('data')
    return projects_response['data']
  end

  error_response(projects_response)
end