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

Add apps resource #330

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-10-07 22:05:47 UTC using RuboCop version 1.66.1.
# on 2024-10-09 19:14:26 UTC using RuboCop version 1.66.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -70,7 +70,7 @@ Metrics/MethodLength:
# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 188
Max: 295

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Expand Down Expand Up @@ -110,7 +110,7 @@ RSpec/ContextWording:
- 'spec/lib/droplet_kit/resources/vpc_resource_spec.rb'
- 'spec/support/resource_context.rb'

# Offense count: 130
# Offense count: 131
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 43
Expand All @@ -125,7 +125,7 @@ RSpec/LeakyConstantDeclaration:
Exclude:
- 'spec/lib/droplet_kit/client_spec.rb'

# Offense count: 129
# Offense count: 131
RSpec/MultipleExpectations:
Max: 30

Expand All @@ -145,7 +145,7 @@ RSpec/NestedGroups:
RSpec/SpecFilePathFormat:
Enabled: false

# Offense count: 186
# Offense count: 293
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false
Expand All @@ -168,6 +168,7 @@ Style/MissingRespondToMissing:
# AllowedMethods: define_method
Style/SymbolProc:
Exclude:
- 'lib/droplet_kit/resources/app_resource.rb'
- 'lib/droplet_kit/resources/container_registry_resource.rb'
- 'lib/droplet_kit/resources/droplet_action_resource.rb'
- 'lib/droplet_kit/resources/kubernetes_cluster_resource.rb'
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,19 @@ Actions supported:
* `client.one_clicks.all(type: 'kubernetes|droplet')`
* `client.one_clicks.create_kubernetes(one_click_kubernetes)`

## App resource

client = DropletKit::Client.new(access_token: 'TOKEN')
client.apps #=> DropletKit::AppResource

Actions supported:

* `client.apps.all(with_projects: bool)`
* `client.apps.find(id: 'id')`
* `client.apps.create(app)`
* `client.apps.update(app, id: 'id')`
* `client.apps.delete(id: 'id')`

## Contributing

1. Fork it ( https://github.com/digitalocean/droplet_kit/fork )
Expand Down
107 changes: 107 additions & 0 deletions lib/droplet_kit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,59 @@ module DropletKit
autoload :VPCPeering, 'droplet_kit/models/vpc_peering'
autoload :OneClick, 'droplet_kit/models/one_click'
autoload :OneClickKubernetes, 'droplet_kit/models/one_click_kubernetes'
autoload :AppDomainSpec, 'droplet_kit/models/app_spec'
autoload :AppGitSourceSpec, 'droplet_kit/models/app_spec'
autoload :AppGitHubSourceSpec, 'droplet_kit/models/app_spec'
autoload :AppGitLabSourceSpec, 'droplet_kit/models/app_spec'
autoload :AppImageDeployOnPush, 'droplet_kit/models/app_spec'
autoload :AppImageSourceSpec, 'droplet_kit/models/app_spec'
autoload :AppVariableDefinition, 'droplet_kit/models/app_spec'
autoload :AppLogDestinationSpecPapertrail, 'droplet_kit/models/app_spec'
autoload :AppLogDestinationSpecDatadog, 'droplet_kit/models/app_spec'
autoload :AppLogDestinationSpecLogtail, 'droplet_kit/models/app_spec'
autoload :OpenSearchBasicAuth, 'droplet_kit/models/app_spec'
autoload :AppLogDestinationSpecOpenSearch, 'droplet_kit/models/app_spec'
autoload :AppLogDestinationSpec, 'droplet_kit/models/app_spec'
autoload :AppAutoscalingSpecMetricCPU, 'droplet_kit/models/app_spec'
autoload :AppAutoscalingSpecMetrics, 'droplet_kit/models/app_spec'
autoload :AppAutoscalingSpec, 'droplet_kit/models/app_spec'
autoload :AppServiceSpecHealthCheck, 'droplet_kit/models/app_spec'
autoload :AppServiceSpecTermination, 'droplet_kit/models/app_spec'
autoload :AppServiceSpec, 'droplet_kit/models/app_spec'
autoload :AppStaticSiteSpec, 'droplet_kit/models/app_spec'
autoload :AppJobSpecTermination, 'droplet_kit/models/app_spec'
autoload :AppJobSpec, 'droplet_kit/models/app_spec'
autoload :AppWorkerSpecTermination, 'droplet_kit/models/app_spec'
autoload :AppWorkerSpec, 'droplet_kit/models/app_spec'
autoload :AppAlertSpec, 'droplet_kit/models/app_spec'
autoload :AppFunctionSpec, 'droplet_kit/models/app_spec'
autoload :AppDatabaseSpec, 'droplet_kit/models/app_spec'
autoload :AppIngressSpecRuleStringMatch, 'droplet_kit/models/app_spec'
autoload :AppIngressSpecRuleMatch, 'droplet_kit/models/app_spec'
autoload :AppStringMatch, 'droplet_kit/models/app_spec'
autoload :AppCorsPolicy, 'droplet_kit/models/app_spec'
autoload :AppIngressSpecRuleRoutingComponent, 'droplet_kit/models/app_spec'
autoload :AppIngressSpecRuleRoutingRedirect, 'droplet_kit/models/app_spec'
autoload :AppIngressSpecRule, 'droplet_kit/models/app_spec'
autoload :AppIngressSpec, 'droplet_kit/models/app_spec'
autoload :AppEgressSpec, 'droplet_kit/models/app_spec'
autoload :AppSpec, 'droplet_kit/models/app_spec'
autoload :DeploymentJob, 'droplet_kit/models/deployment'
autoload :DeploymentFunction, 'droplet_kit/models/deployment'
autoload :DeploymentProgressStepReason, 'droplet_kit/models/deployment'
autoload :DeploymentProgressStep, 'droplet_kit/models/deployment'
autoload :DeploymentProgress, 'droplet_kit/models/deployment'
autoload :DeploymentService, 'droplet_kit/models/deployment'
autoload :DeploymentStaticSite, 'droplet_kit/models/deployment'
autoload :DeploymentWorker, 'droplet_kit/models/deployment'
autoload :Deployment, 'droplet_kit/models/deployment'
autoload :AppDomainProgress, 'droplet_kit/models/app'
autoload :AppDomainSpec, 'droplet_kit/models/app'
autoload :AppDomainValidation, 'droplet_kit/models/app'
autoload :AppDomain, 'droplet_kit/models/app'
autoload :AppRegion, 'droplet_kit/models/app'
autoload :AppDedicatedIp, 'droplet_kit/models/app'
autoload :App, 'droplet_kit/models/app'

# Resources
autoload :DropletResource, 'droplet_kit/resources/droplet_resource'
Expand Down Expand Up @@ -118,6 +171,7 @@ module DropletKit
autoload :VPCResource, 'droplet_kit/resources/vpc_resource'
autoload :VPCPeeringResource, 'droplet_kit/resources/vpc_peering_resource'
autoload :OneClickResource, 'droplet_kit/resources/one_click_resource'
autoload :AppResource, 'droplet_kit/resources/app_resource'

# JSON Maps
autoload :DropletMapping, 'droplet_kit/mappings/droplet_mapping'
Expand Down Expand Up @@ -192,6 +246,59 @@ module DropletKit
autoload :VPCPeeringMapping, 'droplet_kit/mappings/vpc_peering_mapping'
autoload :OneClickMapping, 'droplet_kit/mappings/one_click_mapping'
autoload :OneClickKubernetesMapping, 'droplet_kit/mappings/one_click_kubernetes_mapping'
autoload :AppDomainSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppGitSourceSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppGitHubSourceSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppGitLabSourceSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppImageDeployOnPushMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppImageSourceSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppVariableDefinitionMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppLogDestinationSpecPapertrailMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppLogDestinationSpecDatadogMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppLogDestinationSpecLogtailMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :OpenSearchBasicAuthMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppLogDestinationSpecOpenSearchMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppLogDestinationSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppAutoscalingSpecMetricCPUMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppAutoscalingSpecMetricsMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppAutoscalingSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppServiceSpecHealthCheckMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppServiceSpecTerminationMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppServiceSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppStaticSiteSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppJobSpecTerminationMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppJobSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppWorkerSpecTerminationMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppWorkerSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppAlertSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppFunctionSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppDatabaseSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppIngressSpecRuleStringMatchMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppIngressSpecRuleMatchMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppStringMatchMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppCorsPolicyMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppIngressSpecRuleRoutingComponentMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppIngressSpecRuleRoutingRedirectMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppIngressSpecRuleMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppIngressSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppEgressSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :AppSpecMapping, 'droplet_kit/mappings/app_spec_mapping'
autoload :DeploymentJobMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :DeploymentFunctionMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :DeploymentProgressStepReasonMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :DeploymentProgressStepMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :DeploymentProgressMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :DeploymentServiceMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :DeploymentStaticSiteMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :DeploymentWorkerMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :DeploymentMapping, 'droplet_kit/mappings/deployment_mapping'
autoload :AppDomainProgressMapping, 'droplet_kit/mappings/app_mapping'
autoload :AppDomainSpecMapping, 'droplet_kit/mappings/app_mapping'
autoload :AppDomainValidationMapping, 'droplet_kit/mappings/app_mapping'
autoload :AppDomainMapping, 'droplet_kit/mappings/app_mapping'
autoload :AppRegionMapping, 'droplet_kit/mappings/app_mapping'
autoload :AppDedicatedIpMapping, 'droplet_kit/mappings/app_mapping'
autoload :AppMapping, 'droplet_kit/mappings/app_mapping'

# Utils
autoload :PaginatedResource, 'droplet_kit/paginated_resource'
Expand Down
3 changes: 2 additions & 1 deletion lib/droplet_kit/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def self.resources
volume_actions: VolumeActionResource,
vpcs: VPCResource,
vpc_peerings: VPCPeeringResource,
one_clicks: OneClickResource
one_clicks: OneClickResource,
apps: AppResource
}
end

Expand Down
121 changes: 121 additions & 0 deletions lib/droplet_kit/mappings/app_mapping.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# frozen_string_literal: true

module DropletKit
class AppDomainProgressMapping
include Kartograph::DSL

kartograph do
mapping AppDomainProgress
scoped :read do
property :steps
end
end
end

class AppDomainSpecMapping
include Kartograph::DSL

kartograph do
mapping AppDomainSpec
scoped :read do
property :domain
property :type
property :wildcard
property :zone
property :minimum_tls_version
end
end
end

class AppDomainValidationMapping
include Kartograph::DSL

kartograph do
mapping AppDomainValidation
scoped :read do
property :txt_name
property :txt_value
end
end
end

class AppDomainMapping
include Kartograph::DSL

kartograph do
mapping AppDomain
scoped :read do
property :id
property :phase
property :progress, include: AppDomainProgressMapping
property :spec, include: AppDomainSpecMapping
property :validation, plural: true, include: AppDomainValidationMapping
property :rotate_validation_records
property :certificate_expires_at
end
end
end

class AppRegionMapping
include Kartograph::DSL

kartograph do
mapping AppRegion
scoped :read do
property :continent
property :data_centers
property :default
property :disabled
property :flag
property :label
property :reason
property :slug
end
end
end

class AppDedicatedIpMapping
include Kartograph::DSL

kartograph do
mapping AppDedicatedIp
scoped :read do
property :ip
property :id
property :status
end
end
end

class AppMapping
include Kartograph::DSL

kartograph do
mapping App
root_key plural: 'apps', singular: 'app', scopes: [:read]

property :spec, include: AppSpecMapping, scopes: %i[create update read]
property :project_id, scopes: %i[create read]
property :update_all_source_versions, scopes: [:update]
scoped :read do
property :active_deployment, include: DeploymentMapping
property :created_at
property :default_ingress
property :domains, plural: true, include: AppDomainMapping
property :id
property :in_progress_deployment, include: DeploymentMapping
property :last_deployment_created_at
property :live_domain
property :live_url
property :live_url_base
property :owner_uuid
property :pending_deployment, include: DeploymentMapping
property :region, include: AppRegionMapping
property :tier_slug
property :updated_at
property :pinned_deployment, include: DeploymentMapping
property :dedicated_ips, plural: true, include: AppDedicatedIpMapping
end
end
end
end
Loading
Loading